public function calculate_shipping() { /** @var \jigoshop_tax $_tax */ $_tax = $this->get_tax(); $this->shipping_total = 0; $this->shipping_tax = 0; if ($this->type == 'order') { // Shipping for whole order $this->shipping_total = $this->cost + $this->get_fee($this->fee, jigoshop_cart::$cart_contents_total); $this->shipping_total = $this->shipping_total < 0 ? 0 : $this->shipping_total; // fix flat rate taxes for now. This is old and deprecated, but need to think about how to utilize the total_shipping_tax_amount yet if (Jigoshop_Base::get_options()->get('jigoshop_calc_taxes') == 'yes' && $this->tax_status == 'taxable') { $this->shipping_tax = $this->calculate_shipping_tax($this->shipping_total); } } else { // Shipping per item if (sizeof(jigoshop_cart::$cart_contents) > 0) { foreach (jigoshop_cart::$cart_contents as $item_id => $values) { /** @var jigoshop_product $_product */ $_product = $values['data']; if ($_product->exists() && $values['quantity'] > 0 && !$_product->is_type('downloadable')) { $item_shipping_price = ($this->cost + $this->get_fee($this->fee, $_product->get_price())) * $values['quantity']; $this->shipping_total = $this->shipping_total + $item_shipping_price; //TODO: need to figure out how to handle per item shipping with discounts that apply to shipping as well // * currently not working. Will need to fix if ($_product->is_shipping_taxable() && $this->tax_status == 'taxable') { $_tax->calculate_shipping_tax($item_shipping_price, $this->id, $_product->get_tax_classes()); } } } $this->shipping_tax = $_tax->get_total_shipping_tax_amount(); } } }
function jigoshop_product_list($attributes) { $options = Jigoshop_Base::get_options(); $attributes = shortcode_atts(array('number' => $options->get('jigoshop_catalog_per_page'), 'order_by' => 'date', 'order' => 'desc', 'orientation' => 'rows', 'taxonomy' => 'product_cat', 'terms' => '', 'thumbnails' => 'show', 'sku' => 'hide'), $attributes); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $attributes['number'], 'orderby' => $attributes['order_by'], 'order' => $attributes['order'], 'meta_query' => array(array('key' => 'visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'))); if (!empty($attributes['taxonomy']) && !empty($attributes['terms'])) { $args['tax_query'] = array(array('taxonomy' => $attributes['taxonomy'], 'terms' => $attributes['terms'], 'field' => 'slug')); } $query = new WP_Query($args); remove_action('jigoshop_before_shop_loop_item_title', 'jigoshop_template_loop_product_thumbnail', 10); if ($attributes['thumbnails'] === 'show') { add_action('jigoshop_before_shop_loop_item', 'jigoshop_product_thumbnail', 10, 2); } if ($attributes['sku'] === 'show') { add_action('jigoshop_after_shop_loop_item_title', 'jigoshop_product_sku', 9, 2); } $result = jigoshop_render_result('shortcode/product_list', array('orientation' => $attributes['orientation'], 'products' => $query->get_posts(), 'has_thumbnails' => $attributes['thumbnails'] === 'show')); if ($attributes['sku'] === 'show') { remove_action('jigoshop_after_shop_loop_item_title', 'jigoshop_product_sku', 9); } if ($attributes['thumbnails'] === 'show') { remove_action('jigoshop_before_shop_loop_item', 'jigoshop_product_thumbnail', 10); } add_action('jigoshop_before_shop_loop_item_title', 'jigoshop_template_loop_product_thumbnail', 10, 2); return $result; }
/** * Constructor * Setup the widget with the available options * Add actions to clear the cache whenever a post is saved|deleted or a theme is switched */ public function __construct() { $options = array('classname' => 'jigoshop_cart', 'description' => __('Shopping Cart for the sidebar', 'jigoshop')); // Create the widget parent::__construct('jigoshop_cart', __('Jigoshop: Cart', 'jigoshop'), $options); $this->options = Jigoshop_Base::get_options(); }
public function __construct() { parent::__construct(); $this->paymentKaznacheyUrl = "http://payment.kaznachey.net/api/PaymentInterface/"; $this->id = 'kaznachey'; $this->has_fields = false; $this->kaznachey_init(); $this->enabled = Jigoshop_Base::get_options()->get_option('jigoshop_kaznachey_enabled'); $this->title = Jigoshop_Base::get_options()->get_option('jigoshop_kaznachey_title'); $this->currency = Jigoshop_Base::get_options()->get_option('jigoshop_kaznachey_currency'); $this->language = Jigoshop_Base::get_options()->get_option('jigoshop_kaznachey_language'); $merchnatInfo = $this->GetMerchnatInfo(); if (isset($merchnatInfo["PaySystems"])) { $box = '<br><br><label for="cc_types">Выберите способ оплаты</label><select name="cc_types" id="cc_types">'; foreach ($merchnatInfo["PaySystems"] as $paysystem) { $box .= "<option value='{$paysystem['Id']}'>{$paysystem['PaySystemName']}</option>"; } $box .= '</select><br><input type="checkbox" checked="checked" value="1" name="cc_agreed" id="cc_agreed"><label for="cc_agreed"><a href="' . $merchnatInfo['TermToUse'] . '" target="_blank">Согласен с условиями использования</a></label>'; $box .= "<script type=\"text/javascript\">\n\t\t\t\t(function(){ \n\t\t\t\tvar cc_a = jQuery('#cc_agreed');\n\t\t\t\t\t cc_a.on('click', function(){\n\t\t\t\t\t\tif(cc_a.is(':checked')){\t\n\t\t\t\t\t\t\tjQuery('.custom_gateway').find('.error').text('');\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tcc_a.next().after('<span class=\"error\">Примите условие!</span>');\n\t\t\t\t\t\t}\n\t\t\t\t\t });\n\t\t\t\t\tjQuery('body').on('click', '#place_order', function() {\n\t\t\t\t\t\t document.cookie='cc_types='+jQuery('#cc_types').val();\n\t\t\t\t\t});\t\n\t\t\t\t})(); \n\t\t\t\t</script> "; } $this->description = Jigoshop_Base::get_options()->get_option('jigoshop_kaznachey_description') . $box; add_action('init', array($this, 'check_ipn_response')); add_action('receipt_kaznachey', array($this, 'receipt_kaznachey')); add_action('thankyou_kaznachey', array(&$this, 'thankyou_page')); }
function jigoshop_product_tag($attributes) { global $paged; $jigoshop_options = Jigoshop_Base::get_options(); $attributes = shortcode_atts(array('tag' => '', 'per_page' => $jigoshop_options->get('jigoshop_catalog_per_page'), 'columns' => $jigoshop_options->get('jigoshop_catalog_columns'), 'orderby' => $jigoshop_options->get('jigoshop_catalog_sort_orderby'), 'order' => $jigoshop_options->get('jigoshop_catalog_sort_direction'), 'pagination' => false, 'tax_operator' => 'IN'), $attributes); if (isset($_REQUEST['tag'])) { $attributes['tag'] = $_REQUEST['tag']; } /** Operator validation. */ if (!in_array($attributes['tax_operator'], array('IN', 'NOT IN', 'AND'))) { $tax_operator = 'IN'; } /** Multiple category values. */ if (!empty($slug)) { $slug = explode(',', esc_attr($slug)); $slug = array_map('trim', $slug); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $attributes['per_page'], 'orderby' => $attributes['orderby'], 'order' => $attributes['order'], 'paged' => $paged, 'meta_query' => array(array('key' => 'visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $attributes['tag'], 'operator' => $attributes['tax_operator']))); query_posts($args); ob_start(); jigoshop_get_template_part('loop', 'shop'); if ($attributes['pagination']) { do_action('jigoshop_pagination'); } wp_reset_query(); return ob_get_clean(); }
/** * helper function for any files that do not inherit jigoshop_base, they can access jigoshop_options * @return Jigoshop_Options_Interface the options that have been set, or null if they haven't been set yet */ public static function get_options() { // default options to Jigoshop_Options if they haven't been set if (self::$jigoshop_options == null) { self::$jigoshop_options = new Jigoshop_Options(); } return self::$jigoshop_options; }
/** * Widget * Display the widget in the sidebar * Save output to the cache if empty * * @param array sidebar arguments * @param array instance */ public function widget($args, $instance) { extract($args); // Print the widget wrapper echo $before_widget; if (is_user_logged_in()) { // Get current user instance global $current_user; // Print title $title = $instance['title_user'] ? $instance['title_user'] : __('Hey %s!', 'jigoshop'); if ($title) { echo $before_title . sprintf($title, ucwords($current_user->display_name)) . $after_title; } // Create the default set of links $links = apply_filters('jigoshop_widget_logout_user_links', array(__('My Account', 'jigoshop') => get_permalink(jigoshop_get_page_id('myaccount')), __('Change Password', 'jigoshop') => get_permalink(jigoshop_get_page_id('change_password')), __('Logout', 'jigoshop') => wp_logout_url(home_url()))); } else { // Print title $title = $instance['title_guest'] ? $instance['title_guest'] : __('Login', 'jigoshop'); if ($title) { echo $before_title . $title . $after_title; } do_action('jigoshop_widget_login_before_form'); // Get redirect URI $redirect_to = apply_filters('jigoshop_widget_login_redirect', get_permalink(jigoshop_get_page_id('myaccount'))); $fields = array(); // Support for other plugins which uses GET parameters $fields = apply_filters('jigoshop_get_hidden_fields', $fields); echo "<form action='" . esc_url(wp_login_url($redirect_to)) . "' method='post' class='jigoshop_login_widget'>"; foreach ($fields as $key => $value) { echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />'; } // Username echo "\n\t\t\t<p>\n\t\t\t\t<label for='log'>" . __('Username', 'jigoshop') . "</label>\n\t\t\t\t<input type='text' name='log' id='log' class='input-text username' />\n\t\t\t</p>\n\t\t\t"; // Password echo "\n\t\t\t<p>\n\t\t\t\t<label for='pwd'>" . __('Password', 'jigoshop') . "</label>\n\t\t\t\t<input type='password' name='pwd' id='pwd' class='input-text password' />\n\t\t\t</p>\n\t\t\t"; echo "\n\t\t\t<p>\n\t\t\t\t<input type='submit' name='submit' value='" . __('Login', 'jigoshop') . "' class='input-submit' />\n\t\t\t\t<a class='forgot' href='" . esc_url(wp_lostpassword_url($redirect_to)) . "'>" . __('Forgot it?', 'jigoshop') . "</a>\n\t\t\t</p>\n\t\t\t"; if (Jigoshop_Base::get_options()->get('jigoshop_enable_signup_form') == 'yes') { echo '<p class="register">'; wp_register(__('New user?', 'jigoshop') . ' ', ''); echo '</p>'; } echo "</form>"; do_action('jigoshop_widget_login_after_form'); $links = apply_filters('jigoshop_widget_login_user_links', array()); } // Loop & print out the links if ($links) { echo "\n\t\t\t<nav role='navigation'>\n\t\t\t\t<ul class='pagenav'>"; foreach ($links as $title => $href) { $href = esc_url($href); echo "<li><a title='Go to {$title}' href='{$href}'>{$title}</a></li>"; } echo "\n\t\t\t\t</ul>\n\t\t\t</nav>"; } // Print closing widget wrapper echo $after_widget; }
/** * Process the payment and return the result **/ function process_payment($order_id) { $order = new jigoshop_order($order_id); $status = Jigoshop_Base::get_options()->get('jigoshop_cod_status', 'processing'); $order->update_status($status, __('Waiting for cash delivery.', 'jigoshop')); // Remove cart jigoshop_cart::empty_cart(); // Return thankyou redirect $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks')); return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect)))); }
/** * Get Products matching stock criteria */ public function get_items($current_page, $per_page) { global $wpdb; $this->max_items = 0; $this->items = array(); $options = Jigoshop_Base::get_options(); $stock = absint(max($options->get('jigoshop_notify_no_stock_amount'), 0)); $query_from = apply_filters('jigoshop_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts\n\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id\n\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id\n\t\t\tWHERE 1=1\n\t\t\tAND posts.post_type IN ('product', 'product_variation')\n\t\t\tAND posts.post_status = 'publish'\n\t\t\tAND ((posts.post_type = 'product' AND postmeta2.meta_key = 'manage_stock' AND postmeta2.meta_value = '1') OR (posts.post_type = 'product_variation'))\n\t\t\tAND postmeta.meta_key = 'stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'\n\t\t"); $this->items = $wpdb->get_results($wpdb->prepare("SELECT posts.ID as id, posts.post_parent as parent {$query_from} GROUP BY posts.ID ORDER BY posts.post_title DESC LIMIT %d, %d;", ($current_page - 1) * $per_page, $per_page)); $this->max_items = $wpdb->get_var("SELECT COUNT( DISTINCT posts.ID ) {$query_from};"); }
public function __construct() { parent::__construct(); $this->id = 'cheque'; $this->icon = ''; $this->has_fields = false; $this->enabled = Jigoshop_Base::get_options()->get('jigoshop_cheque_enabled'); $this->title = Jigoshop_Base::get_options()->get('jigoshop_cheque_title'); $this->description = Jigoshop_Base::get_options()->get('jigoshop_cheque_description'); add_action('thankyou_cheque', array(&$this, 'thankyou_page')); }
public function displayFileUpload() { ob_start(); echo '<table>'; if (\FFLCommerce_Base::get_options()->exists('fflcommerce_cart_favicon_count_url')) { echo '<tr><td>' . __('Actual icon:', 'fflcommerce_cart_favicon_count') . '</td><td><img src="' . \Jigoshop_Base::get_options()->get('fflcommerce_cart_favicon_count_url') . '"/></td></tr>'; } echo '<tr><td>' . __('Upload new icon:', 'fflcommerce_cart_favicon_count') . '</td><td><input type="file" id="fflcommerce_cart_favicon_count_file" name="fflcommerce_cart_favicon_count_file" value="" /></td></tr>'; echo '</table>'; return ob_get_clean(); }
function jigoshop_save_attributes() { /** @var $wpdb wpdb */ global $wpdb; $options = Jigoshop_Base::get_options(); if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) { check_admin_referer('jigoshop-add-attribute', '_jigoshop_csrf'); $attribute_label = (string) strip_tags(stripslashes($_POST['attribute_label'])); $attribute_name = !$_POST['attribute_name'] ? sanitize_title(sanitize_user($attribute_label, $strict = true)) : sanitize_title(sanitize_user($_POST['attribute_name'], $strict = true)); $attribute_type = (string) $_POST['attribute_type']; if (empty($attribute_name) && empty($attribute_label) || empty($attribute_label)) { print_r('<div id="message" class="error"><p>' . __('Please enter an attribute label.', 'jigoshop') . '</p></div>'); } elseif ($attribute_name && strlen($attribute_name) < 30 && $attribute_type && !taxonomy_exists('pa_' . sanitize_title($attribute_name))) { $wpdb->insert($wpdb->prefix . "jigoshop_attribute_taxonomies", array('attribute_name' => $attribute_name, 'attribute_label' => $attribute_label, 'attribute_type' => $attribute_type), array('%s', '%s')); do_action('jigoshop_attribute_admin_add_after_save', $attribute_name, $attribute_label, $attribute_type); $options->set('jigowatt_update_rewrite_rules', '1'); wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } else { print_r('<div id="message" class="error"><p>' . __('That attribute already exists, no additions were made.', 'jigoshop') . '</p></div>'); } } elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) { $edit = absint($_GET['edit']); check_admin_referer('jigoshop-edit-attribute_' . $edit, '_jigoshop_csrf'); if ($edit > 0) { $attribute_type = $_POST['attribute_type']; $attribute_label = (string) strip_tags(stripslashes($_POST['attribute_label'])); $wpdb->update($wpdb->prefix . "jigoshop_attribute_taxonomies", array('attribute_type' => $attribute_type, 'attribute_label' => $attribute_label), array('attribute_id' => $_GET['edit']), array('%s', '%s')); do_action('jigoshop_attribute_admin_edit_after_update', $edit, $attribute_label, $attribute_type); } wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } elseif (isset($_GET['delete'])) { $delete = absint($_GET['delete']); check_admin_referer('jigoshop-delete-attribute_' . $delete); if ($delete > 0) { $att_name = $wpdb->get_var($wpdb->prepare("SELECT attribute_name FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = %d", $delete)); if ($att_name && $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = %d", $delete))) { $taxonomy = 'pa_' . sanitize_title($att_name); // Old taxonomy prefix left in for backwards compatibility if (taxonomy_exists($taxonomy)) { $terms = get_terms($taxonomy, 'orderby=name&hide_empty=0'); foreach ($terms as $term) { wp_delete_term($term->term_id, $taxonomy); } } do_action('jigoshop_attribute_admin_delete_after', $delete, $att_name); wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } } } }
public function __construct() { parent::__construct(); $options = Jigoshop_Base::get_options(); $this->id = 'free_shipping'; $this->enabled = $options->get('jigoshop_free_shipping_enabled'); $this->title = $options->get('jigoshop_free_shipping_title'); $this->min_amount = $options->get('jigoshop_free_shipping_minimum_amount'); $this->availability = $options->get('jigoshop_free_shipping_availability'); $this->countries = $options->get('jigoshop_free_shipping_countries'); $session = jigoshop_session::instance(); if (isset($session->chosen_shipping_method_id) && $session->chosen_shipping_method_id == $this->id) { $this->chosen = true; } add_action('jigoshop_settings_scripts', array($this, 'admin_scripts')); }
public function __construct() { parent::__construct(); $options = Jigoshop_Base::get_options(); $this->id = 'local_pickup'; $this->enabled = $options->get('jigoshop_local_pickup_enabled'); $this->title = $options->get('jigoshop_local_pickup_title'); $this->fee = $options->get('jigoshop_local_pickup_handling_fee'); $this->availability = $options->get('jigoshop_local_pickup_availability'); $this->countries = $options->get('jigoshop_local_pickup_countries'); $session = jigoshop_session::instance(); if (isset($session->chosen_shipping_method_id) && $session->chosen_shipping_method_id == $this->id) { $this->chosen = true; } add_action('jigoshop_settings_scripts', array($this, 'admin_scripts')); }
public static function send_mail($hook, array $args = array(), $to) { if (self::can_call_next_action() == false) { return; } $options = \Jigoshop_Base::get_options(); $allowed_templates = $options->get('jigoshop_emails'); if (!$allowed_templates[$hook]) { return; } foreach ($allowed_templates[$hook] as $post_id) { $post = get_post($post_id); if (!empty($post) && $post->post_status == 'publish') { $headers = array('MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8', 'From: "' . self::get_options()->get('jigoshop_email_from_name') . '" <' . self::get_options()->get('jigoshop_email') . '>'); $title = get_post_meta($post_id, 'jigoshop_email_subject', true); $post->post_title = empty($title) ? $post->post_title : $title; $post = self::filter_post($post, $args); $post = self::add_styles($post); $content = $post->post_content; $footer = $options->get('jigoshop_email_footer'); if (Jigoshop_Base::get_options()->get('jigoshop_enable_html_emails', 'no') == 'no') { $template = nl2br(wptexturize($content)); if (!empty($footer)) { $template .= '<br/><br/>' . $footer; } } else { $path = locate_template(array('jigoshop/emails/layout.html')); if (empty($path)) { $path = JIGOSHOP_DIR . '/templates/emails/layout.html'; } if (!empty($footer)) { $footer .= '<br/>'; } $footer .= sprintf(_x('Powered by <a href="%s">Jigoshop</a> - an e-Commerce plugin built on WordPress', 'emails', 'jigoshop'), 'https://www.jigoshop.com'); $title = str_replace('[' . get_bloginfo('name') . '] ', '', $post->post_title); $template = file_get_contents($path); $template = str_replace('{title}', $title, $template); $template = str_replace('{heading}', apply_filters('jigoshop_email_heading', $title), $template); $template = str_replace('{content}', $content, $template); $template = str_replace('{footer}', apply_filters('jigoshop_email_footer', $footer), $template); } wp_mail($to, $post->post_title, $template, $headers); } } }
public function __construct() { parent::__construct(); $options = Jigoshop_Base::get_options(); // Prepare configs $this->icon = PW_JIGO_PLUGIN_URL . '/assets/images/brick_logo.png'; $this->enabled = $options->get('jigoshop_brick_enabled'); $this->title = $options->get('jigoshop_brick_title'); $this->public_key = $options->get('jigoshop_brick_public_key'); $this->private_key = $options->get('jigoshop_brick_private_key'); $this->public_test_key = $options->get('jigoshop_brick_public_test_key'); $this->private_test_key = $options->get('jigoshop_brick_private_test_key'); $this->description = $options->get('jigoshop_brick_description'); $this->testmode = $options->get('jigoshop_brick_testmode'); $this->currency = $options->get('jigoshop_currency'); //$this->notify_url = jigoshop_request_api::query_request('?js-api=jigoshop_brick', false); add_action('receipt_' . $this->id, array($this, 'receipt_page')); }
public function __construct() { parent::__construct(); $this->id = 'paymentwall'; $this->has_fields = false; $this->enabled = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_enabled'); $this->title = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_title'); $this->appkey = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_app_key'); $this->secretkey = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_secret_key'); $this->widget = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_widget'); $this->description = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_description'); $this->thankyoutext = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_thankyoutext'); $this->currency = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_currency'); $this->successurl = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_successurl'); $this->testmode = Jigoshop_Base::get_options()->get_option('jigoshop_paymentwall_testmode'); $this->CREDIT_TYPE_CHARGEBACK = 2; add_action('init', array($this, 'check_ipn_response')); add_action('receipt_paymentwall', array($this, 'receipt_paymentwall')); }
function __construct() { parent::__construct(); $options = Jigoshop_Base::get_options(); $this->id = 'atom'; $this->icon = IMGDIR . 'logo.png'; $this->has_fields = false; $this->enabled = $options->get('jigoshop_atom_enabled'); $this->urls = $options->get('jigoshop_atom_url'); $this->merchant_id = $options->get('jigoshop_atom_merchant_id'); $this->atom_password = $options->get('jigoshop_atom_password'); $this->product_id = $options->get('jigoshop_atom_product_id'); $this->port = $options->get('jigoshop_atom_port'); $this->ssl_version = $options->get('jigoshop_atom_ssl'); $this->notify_url = jigoshop_request_api::query_request('?js-api=JS_Gateway_Paynetz', false); // add_action('jigoshop_settings_scripts', array($this, 'admin_scripts')); add_action('jigoshop_api_js_gateway_paynetz', array($this, 'check_ipn_response')); add_action('receipt_paynetz', array($this, 'receipt_page')); add_action('init', array($this, 'legacy_ipn_response')); }
public function __construct() { parent::__construct(); $options = Jigoshop_Base::get_options(); // Prepare configs $this->icon = PW_JIGO_PLUGIN_URL . '/assets/images/paymentwall_logo.png'; $this->enabled = $options->get('jigoshop_paymentwall_enabled'); $this->title = $options->get('jigoshop_paymentwall_title'); $this->appkey = $options->get('jigoshop_paymentwall_app_key'); $this->secretkey = $options->get('jigoshop_paymentwall_secret_key'); $this->widget = $options->get('jigoshop_paymentwall_widget'); $this->description = $options->get('jigoshop_paymentwall_description'); $this->thankyoutext = $options->get('jigoshop_paymentwall_thankyoutext'); $this->successurl = $options->get('jigoshop_paymentwall_successurl'); $this->testmode = $options->get('jigoshop_paymentwall_testmode'); $this->delivery = $options->get('jigoshop_paymentwall_delivery'); $this->currency = $options->get('jigoshop_currency'); //$this->notify_url = jigoshop_request_api::query_request('?js-api=jigoshop_paymentwall', false); add_action('init', array($this, 'check_ipn_response')); add_action('receipt_' . $this->id, array($this, 'receipt_page')); }
/** * Format decimal numbers according to current settings. * * @param float|string $number Expects either a float or a string with a decimal separator only (no thousands) * @param mixed $dp number of decimal points to use, blank to use configured decimals or false to avoid all rounding. * @param boolean $trim_zeros from end of string * @return string */ function jigoshop_format_decimal($number, $dp = false, $trim_zeros = false) { $locale = localeconv(); $options = Jigoshop_Base::get_options(); $decimals = array($options->get('jigoshop_price_decimal_sep'), $locale['decimal_point'], $locale['mon_decimal_point']); // Remove locale from string if (!is_float($number)) { $number = jigowatt_clean(str_replace($decimals, '.', $number)); } if ($dp !== false) { $dp = intval($dp == "" ? $options->get('jigoshop_price_num_decimals') : $dp); $number = number_format(floatval($number), $dp, '.', ''); // DP is false - don't use number format, just return a string in our format } elseif (is_float($number)) { $number = jigowatt_clean(str_replace($decimals, '.', strval($number))); } if ($trim_zeros && strstr($number, '.')) { $number = rtrim(rtrim($number, '0'), '.'); } return $number; }
/** * Format Bank information to display in emails **/ public static function get_bank_details() { $title = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_title'); $description = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_description'); $bank_name = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_bank_name'); $acc_number = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_acc_number'); $account_holder = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_account_holder'); $sort_code = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_sort_code'); $iban = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_iban'); $bic = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_bic'); $additional = Jigoshop_Base::get_options()->get('jigoshop_bank_transfer_additional'); $bank_info = null; if ($description) { $bank_info .= wpautop(wptexturize($description)) . PHP_EOL; } if ($bank_name) { $bank_info .= __('Bank Name', 'jigoshop') . ": \t" . wptexturize($bank_name) . PHP_EOL; } if ($acc_number) { $bank_info .= __('Account Number', 'jigoshop') . ":\t " . wptexturize($acc_number) . PHP_EOL; } if ($account_holder) { $bank_info .= __('Account Holder', 'jigoshop') . ":\t " . wptexturize($account_holder) . PHP_EOL; } if ($sort_code) { $bank_info .= __('Sort Code', 'jigoshop') . ":\t" . wptexturize($sort_code) . PHP_EOL; } if ($iban) { $bank_info .= __('IBAN', 'jigoshop') . ": \t\t" . wptexturize($iban) . PHP_EOL; } if ($bic) { $bank_info .= __('BIC', 'jigoshop') . ": \t\t " . wptexturize($bic) . PHP_EOL; } if ($additional) { $bank_info .= wpautop(__('Additional Information', 'jigoshop') . ": " . PHP_EOL . wpautop(wptexturize($additional))); } if ($bank_info) { return wpautop($bank_info); } }
/** * Get Jigoshop option * * Jigoshop did some changes on how to retrieve options. * * @param string $key * @return boolean|string */ public static function get_option($key) { $value = false; if (method_exists('Jigoshop_Base', 'get_options')) { $options = Jigoshop_Base::get_options(); if (method_exists($options, 'get')) { // @since Jigoshop v1.12 // @see https://github.com/jigoshop/jigoshop/blob/1.12/gateways/bank_transfer.php $value = $options->get($key); } elseif (method_exists($options, 'get_option')) { // @since Jigoshop v1.3 // @see https://github.com/jigoshop/jigoshop/blob/1.3/gateways/bank_transfer.php $value = $options->get_option($key); } else { // @since Jigoshop v1.2 // @see https://github.com/jigoshop/jigoshop/blob/1.2/gateways/bank_transfer.php $value = get_option($key); } } else { $value = get_option($key); } return $value; }
</td> <td class="help"> </td> <td><?php echo sprintf(_x('by %s', 'by author', 'jigoshop'), $plugin_data['Author']) . ' – ' . esc_html($plugin_data['Version']) . $version_string . $network_string; ?> </td> </tr> <?php } } ?> </tbody> </table> <table class="jigoshop_status_table widefat" cellspacing="0" id="status"> <?php $options = Jigoshop_Base::get_options(); ?> <thead> <tr> <th colspan="3" data-export-label="Settings"><?php _e('Settings', 'jigoshop'); ?> </th> </tr> </thead> <tbody> <tr> <td data-export-label="Taxes Enabled"><?php _e('Taxes Enabled', 'jigoshop'); ?> </td>
function format_tax_rates_for_display($value) { $_tax = new jigoshop_tax(); $tax_classes = $_tax->get_tax_classes(); $tax_rates = Jigoshop_Base::get_options()->get('jigoshop_tax_rates'); if (empty($tax_rates)) { $tax_rates = array(); } $applied_all_states = array(); ob_start(); ?> <div id="jigoshop_tax_rates"> <table class="tax_rate_rules" cellspacing="0"> <thead> <tr> <th><?php _e('Remove', 'jigoshop'); ?> </th> <th><?php _e('Tax Classes', 'jigoshop'); ?> </th> <th><?php _e('Online Label', 'jigoshop'); ?> </th> <th><?php _e('Country/State', 'jigoshop'); ?> </th> <th><?php _e("Rate (%)", 'jigoshop'); ?> </th> <th><?php _e('Apply to shipping', 'jigoshop'); ?> </th> <th><?php _e('Compound', 'jigoshop'); ?> </th> </tr> </thead> <tfoot> <tr> <th><?php _e('Remove', 'jigoshop'); ?> </th> <th><?php _e('Tax Classes', 'jigoshop'); ?> </th> <th><?php _e('Online Label', 'jigoshop'); ?> </th> <th><?php _e('Country/State', 'jigoshop'); ?> </th> <th><?php _e("Rate (%)", 'jigoshop'); ?> </th> <th><?php _e('Apply to shipping', 'jigoshop'); ?> </th> <th><?php _e('Compound', 'jigoshop'); ?> </th> </tr> </tfoot> <tbody> <?php $i = -1; if ($tax_rates && is_array($tax_rates) && sizeof($tax_rates) > 0) { $tax_rates = $this->array_compare($tax_rates); foreach ($tax_rates as $rate) { if (isset($rate['is_all_states']) && in_array($rate['country'] . $rate['class'], $applied_all_states)) { continue; } $i++; // increment counter after check for all states having been applied echo '<tr class="tax_rate"><td><a href="#" class="remove button">×</a></td>'; echo '<td><select id="tax_classes[' . esc_attr($i) . ']" name="tax_classes[' . esc_attr($i) . ']"><option value="*">' . __('Standard Rate', 'jigoshop') . '</option>'; if ($tax_classes) { foreach ($tax_classes as $class) { echo '<option value="' . sanitize_title($class) . '"'; if (isset($rate['class']) && $rate['class'] == sanitize_title($class)) { echo 'selected="selected"'; } echo '>' . $class . '</option>'; } } echo '</select></td>'; echo '<td><input type="text" value="' . esc_attr($rate['label']) . '" name="tax_label[' . esc_attr($i) . ']" placeholder="' . __('Online Label', 'jigoshop') . '" size="10" /></td>'; echo '<td><select name="tax_country[' . esc_attr($i) . '][]" id="tax_country_' . esc_attr($i) . '" class="tax_select2" multiple="multiple" style="width:220px;">'; if (isset($rate['is_all_states'])) { if (is_array($applied_all_states) && !in_array($rate['country'] . $rate['class'], $applied_all_states)) { $applied_all_states[] = $rate['country'] . $rate['class']; jigoshop_countries::country_dropdown_options($rate['country'], '*', true); //all-states } else { continue; } } else { jigoshop_countries::country_dropdown_options($rate['country'], $rate['state'], true); } echo '</select>'; echo '<button class="select_none button">' . __('None', 'jigoshop') . '</button><button class="button select_all">' . __('All', 'jigoshop') . '</button><button class="button select_us_states">' . __('US States', 'jigoshop') . '</button><button class="button select_europe">' . __('EU States', 'jigoshop') . '</button></td>'; echo '<td><input type="text" value="' . esc_attr($rate['rate']) . '" name="tax_rate[' . esc_attr($i) . ']" placeholder="' . __('Rate (%)', 'jigoshop') . '" size="6" /></td>'; echo '<td><input type="checkbox" name="tax_shipping[' . esc_attr($i) . ']" '; if (isset($rate['shipping']) && $rate['shipping'] == 'yes') { echo 'checked="checked"'; } echo ' /></td>'; echo '<td><input type="checkbox" name="tax_compound[' . esc_attr($i) . ']" '; if (isset($rate['compound']) && $rate['compound'] == 'yes') { echo 'checked="checked"'; } echo ' /></td></tr>'; ?> <script type="text/javascript"> /*<![CDATA[*/ jQuery(function() { jQuery("#tax_country_<?php echo esc_attr($i); ?> ").select2(); }); /*]]>*/ </script><?php } } ?> </tbody> </table> <div><a href="#" class="add button"><?php _e('+ Add Tax Rule', 'jigoshop'); ?> </a></div> </div> <script type="text/javascript"> /*<![CDATA[*/ jQuery(function() { jQuery(document.body).on('click', 'tr.tax_rate .select_none', function(){ jQuery(this).closest('td').find('select option').removeAttr("selected"); jQuery(this).closest('td').find('select.tax_select2').trigger("change"); return false; }); jQuery(document.body).on('click', 'tr.tax_rate .select_all', function(){ jQuery(this).closest('td').find('select option').attr("selected","selected"); jQuery(this).closest('td').find('select.tax_select2').trigger("change"); return false; }); jQuery(document.body).on('click', 'tr.tax_rate .select_us_states', function(){ jQuery(this).closest('td').find('select optgroup[label="<?php _e('United States', 'jigoshop'); ?> "] option').attr("selected","selected"); jQuery(this).closest('td').find('select.tax_select2').trigger("change"); return false; }); jQuery(document.body).on('change', 'tr.tax_rate .options select', function(e){ jQuery(this).trigger("liszt:updated"); jQuery(this).closest('td').find('label').text( jQuery(":selected", this).length + ' ' + '<?php _e('countries/states selected', 'jigoshop'); ?> ' ); }); jQuery(document.body).on('click', 'tr.tax_rate .select_europe', function(e){ jQuery(this).closest('td').find('option[value="BE"],option[value="FR"],option[value="DE"],option[value="IT"],option[value="LU"],option[value="NL"],option[value="DK"],option[value="IE"],option[value="GR"],option[value="PT"],option[value="ES"],option[value="AT"],option[value="FI"],option[value="SE"],option[value="CY"],option[value="CZ"],option[value="EE"],option[value="HU"],option[value="LV"],option[value="LT"],option[value="MT"],option[value="PL"],option[value="SK"],option[value="SI"],option[value="RO"],option[value="BG"],option[value="IM"],option[value="GB"]').attr("selected","selected"); jQuery(this).closest('td').find('select.tax_select2').trigger("change"); return false; }); jQuery(document.body).on('click', '#jigoshop_tax_rates a.add', function() { var size = jQuery('.tax_rate_rules tbody tr').size(); jQuery('<tr class="tax_rate"> \ <td><a href="#" class="remove button">×</a></td> \ <td><select name="tax_classes[' + size + ']" > \ <option value="*"><?php _e('Standard Rate', 'jigoshop'); ?> </option> \ <?php $tax_classes = $_tax->get_tax_classes(); if ($tax_classes) { foreach ($tax_classes as $class) { echo '<option value="' . sanitize_title($class) . '">' . $class . '</option>'; } } ?> \ </select></td> \ <td><input type="text" name="tax_label[' + size + ']" placeholder="<?php _e('Online Label', 'jigoshop'); ?> " size="10" /></td> \ <td><select name="tax_country[' + size + '][]" id="tax_country_' + size +'" multiple="multiple" style="width:220px;"> \ <?php jigoshop_countries::country_dropdown_options('', '', true); ?> </select> \ <button class="select_none button"><?php _e('None', 'jigoshop'); ?> </button> \ <button class="button select_all"><?php _e('All', 'jigoshop'); ?> </button> \ <button class="button select_us_states"><?php _e('US States', 'jigoshop'); ?> </button> \ <button class="button select_europe"><?php _e('EU States', 'jigoshop'); ?> </button></td> \ <td><input type="text" name="tax_rate[' + size + ']" placeholder="<?php _e('Rate (%)', 'jigoshop'); ?> " size="6" /> \ <td><input type="checkbox" name="tax_shipping[' + size + ']" /></td> \ <td><input type="checkbox" name="tax_compound[' + size + ']" /></td> \ </tr>' ).appendTo('#jigoshop_tax_rates .tax_rate_rules tbody'); jQuery('#tax_country_' + size).select2(); jQuery('#tax_country_' + size).addClass("tax_select2"); return false; }); jQuery(document.body).on('click', '#jigoshop_tax_rates a.remove', function(){ var answer = confirm("<?php _e('Delete this rule?', 'jigoshop'); ?> "); if (answer) jQuery(this).parent().parent().remove(); return false; }); }); /*]]>*/ </script> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Validate the checkout */ public function validate_checkout() { if (jigoshop_cart::is_empty()) { jigoshop::add_error(sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage →</a>', 'jigoshop'), home_url())); } // Process Discount Codes if (!empty($_POST['coupon_code'])) { $coupon = sanitize_title($_POST['coupon_code']); jigoshop_cart::add_discount($coupon); } foreach (jigoshop_cart::get_coupons() as $coupon) { jigoshop_cart::is_valid_coupon($coupon); } // Checkout fields $this->posted['shipping_method'] = ''; $this->posted['shipping_service'] = ''; if (isset($_POST['shipping_method'])) { $shipping_method = jigowatt_clean($_POST['shipping_method']); $shipping_data = explode(':', $shipping_method); $this->posted['shipping_method'] = $shipping_data[0]; $this->posted['shipping_service'] = $shipping_data[1]; } $this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? jigowatt_clean($_POST['shiptobilling']) : ''; $this->posted['payment_method'] = isset($_POST['payment_method']) ? jigowatt_clean($_POST['payment_method']) : ''; $this->posted['order_comments'] = isset($_POST['order_comments']) ? jigowatt_clean($_POST['order_comments']) : ''; $this->posted['terms'] = isset($_POST['terms']) ? jigowatt_clean($_POST['terms']) : ''; $this->posted['create_account'] = isset($_POST['create_account']) ? jigowatt_clean($_POST['create_account']) : ''; $this->posted['account_username'] = isset($_POST['account_username']) ? jigowatt_clean($_POST['account_username']) : ''; $this->posted['account_password'] = isset($_POST['account_password']) ? jigowatt_clean($_POST['account_password']) : ''; $this->posted['account_password_2'] = isset($_POST['account_password_2']) ? jigowatt_clean($_POST['account_password_2']) : ''; if (jigoshop_cart::get_total(false) == 0) { $this->posted['payment_method'] = 'no_payment'; } // establish customer billing and shipping locations if (jigoshop_cart::ship_to_billing_address_only()) { $this->posted['shiptobilling'] = 'true'; } $country = isset($_POST['billing_country']) ? jigowatt_clean($_POST['billing_country']) : ''; $state = isset($_POST['billing_state']) ? jigowatt_clean($_POST['billing_state']) : ''; $allowed_countries = Jigoshop_Base::get_options()->get('jigoshop_allowed_countries'); if ($allowed_countries === 'specific') { $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries'); if (!in_array($country, $specific_countries)) { jigoshop::add_error(__('Invalid billing country.', 'jigoshop')); return; } } if (jigoshop_countries::country_has_states($country)) { $states = jigoshop_countries::get_states($country); if (!in_array($state, array_keys($states))) { jigoshop::add_error(__('Invalid billing state.', 'jigoshop')); return; } } $postcode = isset($_POST['billing_postcode']) ? jigowatt_clean($_POST['billing_postcode']) : ''; $ship_to_billing = Jigoshop_Base::get_options()->get('jigoshop_ship_to_billing_address_only') == 'yes'; jigoshop_customer::set_location($country, $state, $postcode); if (Jigoshop_Base::get_options()->get('jigoshop_calc_shipping') == 'yes') { if ($ship_to_billing || !empty($_POST['shiptobilling'])) { jigoshop_customer::set_shipping_location($country, $state, $postcode); } else { $country = isset($_POST['shipping_country']) ? jigowatt_clean($_POST['shipping_country']) : ''; $state = isset($_POST['shipping_state']) ? jigowatt_clean($_POST['shipping_state']) : ''; $postcode = isset($_POST['shipping_postcode']) ? jigowatt_clean($_POST['shipping_postcode']) : ''; if ($allowed_countries === 'specific') { $specific_countries = Jigoshop_Base::get_options()->get('jigoshop_specific_allowed_countries'); if (!in_array($country, $specific_countries)) { jigoshop::add_error(__('Invalid shipping country.', 'jigoshop')); return; } } if (jigoshop_countries::country_has_states($country)) { $states = jigoshop_countries::get_states($country); if (!in_array($state, array_keys($states))) { jigoshop::add_error(__('Invalid shipping state.', 'jigoshop')); return; } } jigoshop_customer::set_shipping_location($country, $state, $postcode); } } // Billing Information foreach ($this->billing_fields as $field) { $field = apply_filters('jigoshop_billing_field', $field); $this->posted[$field['name']] = isset($_POST[$field['name']]) ? jigowatt_clean($_POST[$field['name']]) : ''; // Format if (isset($field['format'])) { switch ($field['format']) { case 'postcode': $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break; } } // Required if ($field['name'] == 'billing_state' && jigoshop_customer::has_valid_shipping_state()) { $field['required'] = false; } if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) { jigoshop::add_error($field['label'] . __(' (billing) is a required field.', 'jigoshop')); } if ($field['name'] == 'billing_euvatno') { $vatno = isset($this->posted['billing_euvatno']) ? $this->posted['billing_euvatno'] : ''; $vatno = str_replace(' ', '', $vatno); $country = jigoshop_tax::get_customer_country(); // strip any country code from the beginning of the number if (strpos($vatno, $country) === 0) { $vatno = substr($vatno, strlen($country)); } if ($vatno != '') { $url = 'http://isvat.appspot.com/' . $country . '/' . $vatno . '/'; $httpRequest = curl_init(); curl_setopt($httpRequest, CURLOPT_FAILONERROR, true); curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, true); curl_setopt($httpRequest, CURLOPT_HEADER, false); curl_setopt($httpRequest, CURLOPT_URL, $url); $result = curl_exec($httpRequest); curl_close($httpRequest); if ($result === 'false') { jigoshop_log('EU VAT validation error with URL: ' . $url); jigoshop::add_error($field['label'] . __(' (billing) is not a valid VAT Number. Leave it blank to disable VAT validation. (VAT may be charged depending on your location)', 'jigoshop')); } else { $this->valid_euvatno = jigoshop_countries::get_base_country() != jigoshop_tax::get_customer_country() && jigoshop_countries::is_eu_country(jigoshop_tax::get_customer_country()); } } } // Validation if (isset($field['validate']) && !empty($this->posted[$field['name']])) { switch ($field['validate']) { case 'phone': if (!jigoshop_validation::is_phone($this->posted[$field['name']])) { jigoshop::add_error($field['label'] . __(' (billing) is not a valid number.', 'jigoshop')); } break; case 'email': if (!jigoshop_validation::is_email($this->posted[$field['name']])) { jigoshop::add_error($field['label'] . __(' (billing) is not a valid email address.', 'jigoshop')); } break; case 'postcode': if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $_POST['billing_country'])) { jigoshop::add_error($field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'jigoshop')); } else { $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $_POST['billing_country']); } break; } } } // Shipping Information if (jigoshop_shipping::is_enabled() && !jigoshop_cart::ship_to_billing_address_only() && empty($this->posted['shiptobilling'])) { foreach ($this->shipping_fields as $field) { $field = apply_filters('jigoshop_shipping_field', $field); if (isset($_POST[$field['name']])) { $this->posted[$field['name']] = jigowatt_clean($_POST[$field['name']]); } else { $this->posted[$field['name']] = ''; } // Format if (isset($field['format'])) { switch ($field['format']) { case 'postcode': $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break; } } // Required if ($field['name'] == 'shipping_state' && jigoshop_customer::has_valid_shipping_state()) { $field['required'] = false; } if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) { jigoshop::add_error($field['label'] . __(' (shipping) is a required field.', 'jigoshop')); } // Validation if (isset($field['validate']) && !empty($this->posted[$field['name']])) { switch ($field['validate']) { case 'postcode': if (!jigoshop_validation::is_postcode($this->posted[$field['name']], $country)) { jigoshop::add_error($field['label'] . __(' (shipping) is not a valid postcode/ZIP.', 'jigoshop')); } else { $this->posted[$field['name']] = jigoshop_validation::format_postcode($this->posted[$field['name']], $country); } break; } } } } if ($this->must_register && empty($this->posted['create_account'])) { jigoshop::add_error(__('Sorry, you must agree to creating an account', 'jigoshop')); } if ($this->must_register || empty($user_id) && $this->posted['create_account']) { if (!$this->show_signup) { jigoshop::add_error(__('Sorry, the shop owner has disabled guest purchases.', 'jigoshop')); } if (empty($this->posted['account_username'])) { jigoshop::add_error(__('Please enter an account username.', 'jigoshop')); } if (empty($this->posted['account_password'])) { jigoshop::add_error(__('Please enter an account password.', 'jigoshop')); } if ($this->posted['account_password_2'] !== $this->posted['account_password']) { jigoshop::add_error(__('Passwords do not match.', 'jigoshop')); } // Check the username if (!validate_username($this->posted['account_username'])) { jigoshop::add_error(__('Invalid email/username.', 'jigoshop')); } elseif (username_exists($this->posted['account_username'])) { jigoshop::add_error(__('An account is already registered with that username. Please choose another.', 'jigoshop')); } // Check the e-mail address if (email_exists($this->posted['billing_email'])) { jigoshop::add_error(__('An account is already registered with your email address. Please login.', 'jigoshop')); } } // Terms if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && jigoshop_get_page_id('terms') > 0) { jigoshop::add_error(__('You must accept our Terms & Conditions.', 'jigoshop')); } if (jigoshop_cart::needs_shipping()) { // Shipping Method $available_methods = jigoshop_shipping::get_available_shipping_methods(); if (!isset($available_methods[$this->posted['shipping_method']])) { jigoshop::add_error(__('Invalid shipping method.', 'jigoshop')); } } }
/** * Product data box * * Displays the product data box, tabbed, with several panels covering price, stock etc * * @since 1.0 */ function jigoshop_product_data_box() { global $post, $wpdb, $thepostid; add_action('admin_footer', 'jigoshop_meta_scripts'); wp_nonce_field('jigoshop_save_data', 'jigoshop_meta_nonce'); $thepostid = $post->ID; // Product Type $terms = get_the_terms($thepostid, 'product_type'); $product_type = $terms ? current($terms)->slug : 'simple'; $product_type_selector = apply_filters('jigoshop_product_type_selector', array('simple' => __('Simple', 'jigoshop'), 'downloadable' => __('Downloadable', 'jigoshop'), 'grouped' => __('Grouped', 'jigoshop'), 'virtual' => __('Virtual', 'jigoshop'), 'variable' => __('Variable', 'jigoshop'), 'external' => __('External / Affiliate', 'jigoshop'))); $product_type_select = '<div class="product-type-label">' . __('Product Type', 'jigoshop') . '</div><select id="product-type" name="product-type"><optgroup label="' . __('Product Type', 'jigoshop') . '">'; foreach ($product_type_selector as $value => $label) { $product_type_select .= '<option value="' . $value . '" ' . selected($product_type, $value, false) . '>' . $label . '</option>'; } $product_type_select .= '</optgroup></select><div class="clear"></div>'; ?> <div class="panels"> <span class="jigoshop_product_data_type"><?php echo $product_type_select; ?> </span> <ul class="product_data_tabs tabs" style="display:none;"> <li class="general_tab active"> <a href="#general"><?php _e('General', 'jigoshop'); ?> </a> </li> <li class="advanced_tab"> <a href="#tax"><?php _e('Advanced', 'jigoshop'); ?> </a> </li> <?php if (Jigoshop_Base::get_options()->get('jigoshop_manage_stock') == 'yes') { ?> <li class="inventory_tab"> <a href="#inventory"><?php _e('Inventory', 'jigoshop'); ?> </a> </li> <?php } ?> <li class="attributes_tab"> <a href="#attributes"><?php _e('Attributes', 'jigoshop'); ?> </a> </li> <li class="grouped_tab"> <a href="#grouped"><?php _e('Grouping', 'jigoshop'); ?> </a> </li> <li class="file_tab"> <a href="#files"><?php _e('Download', 'jigoshop'); ?> </a> </li> <?php do_action('jigoshop_product_write_panel_tabs'); ?> <?php do_action('product_write_panel_tabs'); ?> </ul> <div id="general" class="panel jigoshop_options_panel"> <fieldset> <?php // Visibility $args = array('id' => 'product_visibility', 'label' => __('Visibility', 'jigoshop'), 'options' => array('visible' => __('Catalog & Search', 'jigoshop'), 'catalog' => __('Catalog Only', 'jigoshop'), 'search' => __('Search Only', 'jigoshop'), 'hidden' => __('Hidden', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'visibility', true)); echo Jigoshop_Forms::select($args); // Featured $args = array('id' => 'featured', 'label' => __('Featured?', 'jigoshop'), 'desc' => __('Enable this option to feature this product', 'jigoshop'), 'value' => false); echo Jigoshop_Forms::checkbox($args); ?> </fieldset> <fieldset> <?php // SKU if (Jigoshop_Base::get_options()->get('jigoshop_enable_sku') !== 'no') { $args = array('id' => 'sku', 'label' => __('SKU', 'jigoshop'), 'placeholder' => $post->ID); echo Jigoshop_Forms::input($args); } //Brand if (Jigoshop_Base::get_options()->get('jigoshop_enable_brand') !== 'no') { $args = array('id' => 'brand', 'label' => __('Brand', 'jigoshop')); echo Jigoshop_Forms::input($args); } //GTIN if (Jigoshop_Base::get_options()->get('jigoshop_enable_gtin ') !== 'no') { $args = array('id' => 'gtin', 'label' => __('GTIN ', 'jigoshop')); echo Jigoshop_Forms::input($args); } //MPN if (Jigoshop_Base::get_options()->get('jigoshop_enable_mpn') !== 'no') { $args = array('id' => 'mpn', 'label' => __('MPN', 'jigoshop')); echo Jigoshop_Forms::input($args); } ?> </fieldset> <fieldset id="price_fieldset"> <?php // Regular Price $args = array('id' => 'regular_price', 'label' => __('Regular Price', 'jigoshop'), 'after_label' => ' (' . get_jigoshop_currency_symbol() . ')', 'type' => 'number', 'step' => 'any', 'placeholder' => __('Price Not Announced', 'jigoshop')); echo Jigoshop_Forms::input($args); // Sale Price $args = array('id' => 'sale_price', 'label' => __('Sale Price', 'jigoshop'), 'after_label' => ' (' . get_jigoshop_currency_symbol() . __(' or %', 'jigoshop') . ')', 'desc' => '<a href="#" class="sale_schedule">' . __('Schedule', 'jigoshop') . '</a>', 'placeholder' => __('15% or 19.99', 'jigoshop')); echo Jigoshop_Forms::input($args); // Sale Price date range // TODO: Convert this to a helper somehow? $field = array('id' => 'sale_price_dates', 'label' => __('On Sale Between', 'jigoshop')); $sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true); $sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true); echo '<p class="form-field sale_price_dates_fields">' . __('Current time:', 'jigoshop') . ' ' . current_time('Y-m-d H:i') . '</p>'; echo ' <p class="form-field sale_price_dates_fields"> <label for="' . esc_attr($field['id']) . '_from">' . $field['label'] . '</label> <input type="text" class="short date-pick" name="' . esc_attr($field['id']) . '_from" id="' . esc_attr($field['id']) . '_from" value="'; if ($sale_price_dates_from) { echo date('Y-m-d H:i', $sale_price_dates_from); } echo '" placeholder="' . __('From', 'jigoshop') . ' (' . date('Y-m-d H:i') . ')" maxlength="16" /> <input type="text" class="short date-pick" name="' . esc_attr($field['id']) . '_to" id="' . esc_attr($field['id']) . '_to" value="'; if ($sale_price_dates_to) { echo date('Y-m-d H:i', $sale_price_dates_to); } echo '" placeholder="' . __('To', 'jigoshop') . ' (' . date('Y-m-d H:i') . ')" maxlength="16" /> <a href="#" class="cancel_sale_schedule">' . __('Cancel', 'jigoshop') . '</a> </p>'; ?> <?php do_action('jigoshop_product_pricing_options'); /* allow extensions like sales flash pro to add pricing options */ ?> </fieldset> <fieldset> <?php // External products $args = array('id' => 'external_url', 'label' => __('Product URL', 'jigoshop'), 'placeholder' => __('The URL of the external product (eg. http://www.google.com)', 'jigoshop'), 'extras' => array()); echo Jigoshop_Forms::input($args); ?> </fieldset> <?php do_action('jigoshop_product_general_panel'); ?> </div> <div id="tax" class="panel jigoshop_options_panel"> <fieldset id="tax_fieldset"> <?php // Tax Status $status = get_post_meta($post->ID, 'tax_status', true); if (empty($status)) { $status = Jigoshop_Base::get_options()->get('jigoshop_tax_defaults_status', 'taxable'); } $args = array('id' => 'tax_status', 'label' => __('Tax Status', 'jigoshop'), 'options' => array('taxable' => __('Taxable', 'jigoshop'), 'shipping' => __('Shipping', 'jigoshop'), 'none' => __('None', 'jigoshop')), 'selected' => $status); echo Jigoshop_Forms::select($args); ?> <p class="form_field tax_classes_field"> <label for="tax_classes"><?php _e('Tax Classes', 'jigoshop'); ?> </label> <span class="multiselect short"> <?php $_tax = new jigoshop_tax(); $tax_classes = $_tax->get_tax_classes(); $selections = get_post_meta($post->ID, 'tax_classes', true); if (!is_array($selections)) { $selections = Jigoshop_Base::get_options()->get('jigoshop_tax_defaults_classes', array('*')); } $checked = checked(in_array('*', $selections), true, false); printf('<label %s><input type="checkbox" name="tax_classes[]" value="%s" %s/> %s</label>', !empty($checked) ? 'class="selected"' : '', '*', $checked, __('Standard', 'jigoshop')); if ($tax_classes) { foreach ($tax_classes as $tax_class) { $checked = checked(in_array(sanitize_title($tax_class), $selections), true, false); printf('<label %s><input type="checkbox" name="tax_classes[]" value="%s" %s/> %s</label>', !empty($checked) ? 'class="selected"' : '', sanitize_title($tax_class), $checked, __($tax_class, 'jigoshop')); } } ?> </span> <span class="multiselect-controls"> <a class="check-all" href="#"><?php _e('Check All', 'jigoshop'); ?> </a> | <a class="uncheck-all" href="#"><?php _e('Uncheck All', 'jigoshop'); ?> </a> </span> </p> </fieldset> <?php if (Jigoshop_Base::get_options()->get('jigoshop_enable_weight') !== 'no' || Jigoshop_Base::get_options()->get('jigoshop_enable_dimensions', true) !== 'no') { ?> <fieldset id="form_fieldset"> <?php // Weight if (Jigoshop_Base::get_options()->get('jigoshop_enable_weight') !== 'no') { $args = array('id' => 'weight', 'label' => __('Weight', 'jigoshop'), 'after_label' => ' (' . Jigoshop_Base::get_options()->get('jigoshop_weight_unit') . ')', 'type' => 'number', 'step' => 'any', 'placeholder' => '0.00'); echo Jigoshop_Forms::input($args); } // Dimensions if (Jigoshop_Base::get_options()->get('jigoshop_enable_dimensions', true) !== 'no') { echo ' <p class="form-field dimensions_field"> <label for"product_length">' . __('Dimensions', 'jigoshop') . ' (' . Jigoshop_Base::get_options()->get('jigoshop_dimension_unit') . ')' . '</label> <input type="number" step="any" name="length" class="short" value="' . get_post_meta($thepostid, 'length', true) . '" placeholder="' . __('Length', 'jigoshop') . '" /> <input type="number" step="any" name="width" class="short" value="' . get_post_meta($thepostid, 'width', true) . '" placeholder="' . __('Width', 'jigoshop') . '" /> <input type="number" step="any" name="height" class="short" value="' . get_post_meta($thepostid, 'height', true) . '" placeholder="' . __('Height', 'jigoshop') . '" /> </p> '; } ?> </fieldset> <?php } ?> <fieldset> <?php // Customizable $args = array('id' => 'product_customize', 'label' => __('Can be personalized', 'jigoshop'), 'options' => array('no' => __('No', 'jigoshop'), 'yes' => __('Yes', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'customizable', true)); echo Jigoshop_Forms::select($args); // Customizable length $args = array('id' => 'customized_length', 'label' => __('Personalized Characters', 'jigoshop'), 'type' => 'number', 'value' => get_post_meta($post->ID, 'customized_length', true), 'placeholder' => __('Leave blank for unlimited', 'jigoshop')); echo Jigoshop_Forms::input($args); ?> </fieldset> <?php do_action('jigoshop_product_tax_panel'); ?> </div> <?php if (Jigoshop_Base::get_options()->get('jigoshop_manage_stock') == 'yes') { ?> <div id="inventory" class="panel jigoshop_options_panel"> <fieldset> <?php // manage stock $args = array('id' => 'manage_stock', 'label' => __('Manage Stock?', 'jigoshop'), 'desc' => __('Handle stock for me', 'jigoshop'), 'value' => false); echo Jigoshop_Forms::checkbox($args); ?> </fieldset> <fieldset> <?php // Stock Status // TODO: These values should be true/false $args = array('id' => 'stock_status', 'label' => __('Stock Status', 'jigoshop'), 'options' => array('instock' => __('In Stock', 'jigoshop'), 'outofstock' => __('Out of Stock', 'jigoshop'))); echo Jigoshop_Forms::select($args); echo '<div class="stock_fields">'; // Stock // TODO: Missing default value of 0 $args = array('id' => 'stock', 'label' => __('Stock Quantity', 'jigoshop'), 'type' => 'number'); echo Jigoshop_Forms::input($args); // Backorders $args = array('id' => 'backorders', 'label' => __('Allow Backorders?', 'jigoshop'), 'options' => array('no' => __('Do not allow', 'jigoshop'), 'notify' => __('Allow, but notify customer', 'jigoshop'), 'yes' => __('Allow', 'jigoshop'))); echo Jigoshop_Forms::select($args); echo '</div>'; ?> </fieldset> <?php do_action('jigoshop_product_inventory_panel'); ?> </div> <?php } ?> <div id="attributes" class="panel"> <?php do_action('jigoshop_attributes_display'); ?> </div> <div id="grouped" class="panel jigoshop_options_panel"> <?php // Grouped Products // TODO: Needs refactoring & a bit of love $posts_in = (array) get_objects_in_term(get_term_by('slug', 'grouped', 'product_type')->term_id, 'product_type'); $posts_in = array_unique($posts_in); if ((bool) $posts_in) { $args = array('post_type' => 'product', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc', 'post_parent' => 0, 'include' => $posts_in); $grouped_products = get_posts($args); $options = array(null => '– Pick a Product Group –'); if ($grouped_products) { foreach ($grouped_products as $product) { if ($product->ID == $post->ID) { continue; } $options[$product->ID] = $product->post_title; } } // Only echo the form if we have grouped products $args = array('id' => 'parent_id', 'label' => __('Product Group', 'jigoshop'), 'options' => $options, 'selected' => $post->post_parent); echo Jigoshop_Forms::select($args); } // Ordering $args = array('id' => 'menu_order', 'label' => __('Sort Order', 'jigoshop'), 'type' => 'number', 'value' => $post->menu_order); echo Jigoshop_Forms::input($args); $args = array('id' => 'variation_order', 'label' => __('Variation Order', 'jigoshop'), 'options' => array('asort' => __('By name ascending', 'jigoshop'), 'arsort' => __('By name descending', 'jigoshop'), 'ksort' => __('From first to last key', 'jigoshop'), 'krsort' => __('From last to first key', 'jigoshop'), 'shuffle' => __('Random', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'variation_order', true)); echo Jigoshop_Forms::select($args); ?> <?php do_action('jigoshop_product_grouped_panel'); ?> </div> <div id="files" class="panel jigoshop_options_panel"> <fieldset> <?php // DOWNLOADABLE OPTIONS // File URL // TODO: Refactor this into a helper $file_path = get_post_meta($post->ID, 'file_path', true); $field = array('id' => 'file_path', 'label' => __('File Path', 'jigoshop')); echo '<p class="form-field"><label for="' . esc_attr($field['id']) . '">' . $field['label'] . ':</label> <input type="text" class="file_path" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($file_path) . '" placeholder="' . site_url() . '" /> <input type="button" class="upload_file_button button" data-postid="' . esc_attr($post->ID) . '" value="' . __('Upload a file', 'jigoshop') . '" /> </p>'; // Download Limit $args = array('id' => 'download_limit', 'label' => __('Download Limit', 'jigoshop'), 'type' => 'number', 'desc' => __('Leave blank for unlimited re-downloads', 'jigoshop')); echo Jigoshop_Forms::input($args); do_action('additional_downloadable_product_type_options'); ?> </fieldset> <?php do_action('jigoshop_product_files_panel'); ?> </div> <?php do_action('jigoshop_product_write_panels'); ?> <?php do_action('product_write_panels'); ?> </div> <?php }
/** * SIZES */ function yiw_get_jigoshop_size($size) { global $jigoshop_options; if (!isset($jigoshop_options) || empty($jigoshop_options)) { $jigoshop_options = Jigoshop_Base::get_options(); } return $jigoshop_options->get_option($size); }
/** * Return currency tooltip JS based on jigoshop currency position settings. * * @return string */ public function get_currency_tooltip() { $options = Jigoshop_Base::get_options(); switch ($options->get('jigoshop_currency_pos')) { case 'right': $currency_tooltip = 'append_tooltip: "' . get_jigoshop_currency_symbol() . '"'; break; case 'right_space': $currency_tooltip = 'append_tooltip: " ' . get_jigoshop_currency_symbol() . '"'; break; case 'left': $currency_tooltip = 'prepend_tooltip: "' . get_jigoshop_currency_symbol() . '"'; break; case 'left_space': default: $currency_tooltip = 'prepend_tooltip: "' . get_jigoshop_currency_symbol() . ' "'; break; } return $currency_tooltip; }
function jigoshop_sale_products($atts) { global $columns, $per_page, $paged; extract(shortcode_atts(array('per_page' => Jigoshop_Base::get_options()->get('jigoshop_catalog_per_page'), 'columns' => Jigoshop_Base::get_options()->get('jigoshop_catalog_columns'), 'orderby' => Jigoshop_Base::get_options()->get('jigoshop_catalog_sort_orderby'), 'order' => Jigoshop_Base::get_options()->get('jigoshop_catalog_sort_direction'), 'pagination' => false), $atts)); $ids = jigoshop_product::get_product_ids_on_sale(); if (empty($ids)) { $ids = array('0'); } $args = array('post_status' => 'publish', 'post_type' => 'product', 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'post__in' => $ids); query_posts($args); ob_start(); jigoshop_get_template_part('loop', 'shop'); if ($pagination) { do_action('jigoshop_pagination'); } wp_reset_postdata(); return ob_get_clean(); }
/** * Properly sets the WP Nav Menus items classes for jigoshop queried objects * * @param $menu_items * @param array $args * @return * @TODO set parent items classes when the shop page is not at the nav menu root */ function jigoshop_nav_menu_items_classes($menu_items, $args) { $options = Jigoshop_Base::get_options(); $shop_page_id = (int) jigoshop_get_page_id('shop'); // only add nav menu classes if the queried object is the Shop page or derivative (Product, Category, Tag) if (empty($shop_page_id) || !is_content_wrapped()) { return $menu_items; } $home_page_id = (int) $options->get('page_for_posts'); foreach ((array) $menu_items as $key => $menu_item) { $classes = (array) $menu_item->classes; // unset classes set by WP on the home page item // shouldn't need a content wrap check as we can't get here without it -JAP- if (is_content_wrapped() && $home_page_id == $menu_item->object_id) { $menu_items[$key]->current = false; unset($classes[array_search('current_page_parent', $classes)]); unset($classes[array_search('current-menu-item', $classes)]); } if (is_shop() && $shop_page_id == $menu_item->object_id) { // is products archive $menu_items[$key]->current = true; $classes[] = 'current-menu-item'; $classes[] = 'current_page_item'; } elseif ((is_product() || is_product_category() || is_product_tag()) && $shop_page_id == $menu_item->object_id) { // is another jigoshop object $classes[] = 'current_page_parent'; $classes[] = 'current_menu_parent'; } $menu_items[$key]->classes = array_unique($classes); } return $menu_items; }