selected_rate_id); // Process Discount Codes if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && jigoshop::verify_nonce('cart')) : $coupon_code = stripslashes(trim($_POST['coupon_code'])); jigoshop_cart::add_discount($coupon_code); // Update Shipping elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && jigoshop::verify_nonce('cart')) : unset( jigoshop_session::instance()->chosen_shipping_method_id ); $country = $_POST['calc_shipping_country']; $state = $_POST['calc_shipping_state']; $postcode = $_POST['calc_shipping_postcode']; if ($postcode && !jigoshop_validation::is_postcode($postcode, $country)) : jigoshop::add_error(__('Please enter a valid postcode/ZIP.', 'jigoshop')); $postcode = ''; elseif ($postcode) : $postcode = jigoshop_validation::format_postcode($postcode, $country); endif; if ($country) : // Update customer location jigoshop_customer::set_location($country, $state, $postcode); jigoshop_customer::set_shipping_location($country, $state, $postcode); jigoshop::add_message(__('Shipping costs updated.', 'jigoshop')); else : jigoshop_customer::set_shipping_location('', '', ''); jigoshop::add_message(__('Shipping costs updated.', 'jigoshop')); endif; elseif (isset($_POST['shipping_rates'])) : $rates_params = explode(":", $_POST['shipping_rates']); if ($rates_params[1] != NULL) : jigoshop_session::instance()->selected_rate_id = $rates_params[1]; else : jigoshop_session::instance()->selected_rate_id = 'no_rate_id'; // where are constants stored? to find out endif; $available_methods = jigoshop_shipping::get_available_shipping_methods(); $available_methods[$rates_params[0]]->choose(); // choses the method selected by user. endif; // Re-Calc prices. This needs to happen every time the cart page is loaded and after checking post results. It will happen twice for coupon. jigoshop_cart::calculate_totals(); $result = jigoshop_cart::check_cart_item_stock(); if (is_wp_error($result)) : jigoshop::add_error($result->get_error_message()); endif; jigoshop::show_messages(); if (sizeof(jigoshop_cart::$cart_contents) == 0) : echo '
' . __('Your cart is empty.', 'jigoshop') . '
'; ?>- | ||