function jigoshop_init() { // Override default translations with custom .mo's found in wp-content/languages/jigoshop first. load_textdomain('jigoshop', WP_LANG_DIR . '/jigoshop/jigoshop-' . get_locale() . '.mo'); load_plugin_textdomain('jigoshop', false, dirname(plugin_basename(__FILE__)) . '/languages/'); add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'jigoshop_admin_bar_links'); do_action('before_jigoshop_init'); // instantiate options -after- loading text domains $options = Jigoshop_Base::get_options(); jigoshop_post_type(); // register taxonomies new jigoshop_cron(); // -after- text domains and Options instantiation allows settings translations jigoshop_set_image_sizes(); // called -after- our Options are loaded // add Singletons here so that the taxonomies are loaded before calling them. jigoshop_session::instance(); // Start sessions if they aren't already jigoshop::instance(); // Utility functions, uses sessions jigoshop_customer::instance(); // Customer class, sorts session data such as location // Jigoshop will instantiate gateways and shipping methods on this same 'init' action hook // with a very low priority to ensure text domains are loaded first prior to installing any external options jigoshop_shipping::instance(); // Shipping class. loads shipping methods jigoshop_payment_gateways::instance(); // Payment gateways class. loads payment methods jigoshop_cart::instance(); // Cart class, uses sessions add_filter('mce_external_plugins', 'jigoshop_register_shortcode_editor'); add_filter('mce_buttons', 'jigoshop_register_shortcode_buttons'); if (!is_admin()) { /* Catalog Filters */ add_filter('loop-shop-query', create_function('', 'return array("orderby" => "' . $options->get('jigoshop_catalog_sort_orderby') . '","order" => "' . $options->get('jigoshop_catalog_sort_direction') . '");')); add_filter('loop_shop_columns', create_function('', 'return ' . $options->get('jigoshop_catalog_columns') . ';')); add_filter('loop_shop_per_page', create_function('', 'return ' . $options->get('jigoshop_catalog_per_page') . ';')); jigoshop_catalog_query::instance(); // front end queries class jigoshop_request_api::instance(); // front end request api for URL's } jigoshop_roles_init(); do_action('jigoshop_initialize_plugins'); }
function jigoshop_ajax_update_item_quantity() { /** @var jigoshop_cart $cart */ $cart = jigoshop_cart::instance(); $cart->set_quantity($_POST['item'], (int) $_POST['qty']); $items = $cart->get_cart(); $price = -1; if (isset($items[$_POST['item']])) { $item = $items[$_POST['item']]; /** @var jigoshop_product $product */ $product = $item['data']; $price = apply_filters('jigoshop_product_subtotal_display_in_cart', jigoshop_price($product->get_defined_price() * $item['quantity']), $item['product_id'], $item); } if (jigoshop_cart::show_retail_price()) { $subtotal = jigoshop_cart::get_cart_subtotal(true, false, true); } else { if (jigoshop_cart::show_retail_price() && Jigoshop_Base::get_options()->get('jigoshop_prices_include_tax') == 'no') { $subtotal = jigoshop_cart::get_cart_subtotal(true, true); } else { $subtotal = jigoshop_cart::$cart_contents_total_ex_tax; $subtotal = jigoshop_price($subtotal, array('ex_tax_label' => 1)); } } $tax = array(); foreach (jigoshop_cart::get_applied_tax_classes() as $tax_class) { if (jigoshop_cart::get_tax_for_display($tax_class)) { $tax[$tax_class] = jigoshop_cart::get_tax_amount($tax_class); } } $shipping = jigoshop_cart::get_cart_shipping_total(true, true) . '<small>' . jigoshop_cart::get_cart_shipping_title() . '</small>'; $discount = '-' . jigoshop_cart::get_total_discount(); $total = jigoshop_cart::get_total(); echo json_encode(array('success' => true, 'item_price' => $price, 'subtotal' => $subtotal, 'shipping' => $shipping, 'discount' => $discount, 'tax' => $tax, 'total' => $total)); exit; }