function woocommerce_ajax_update_shipping_method() { global $woocommerce; check_ajax_referer('update-shipping-method', 'security'); if (isset($_POST['shipping_method'])) { $_SESSION['_chosen_shipping_method'] = $_POST['shipping_method']; } $woocommerce->cart->calculate_totals(); woocommerce_cart_totals(); die; }
/** * AJAX update shipping method on cart page * * @access public * @return void */ function woocommerce_ajax_update_shipping_method() { global $woocommerce; check_ajax_referer('update-shipping-method', 'security'); if (!defined('WOOCOMMERCE_CART')) { define('WOOCOMMERCE_CART', true); } if (isset($_POST['shipping_method'])) { $woocommerce->session->chosen_shipping_method = $_POST['shipping_method']; } $woocommerce->cart->calculate_totals(); woocommerce_cart_totals(); die; }
/** * AJAX update shipping method on cart page */ public static function update_shipping_method() { check_ajax_referer('update-shipping-method', 'security'); if (!defined('WOOCOMMERCE_CART')) { define('WOOCOMMERCE_CART', true); } $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) { foreach ($_POST['shipping_method'] as $i => $value) { $chosen_shipping_methods[$i] = wc_clean($value); } } WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods); WC()->cart->calculate_totals(); woocommerce_cart_totals(); die; }
<?php do_action('woocommerce_after_cart_contents'); ?> </tbody> </table> <?php do_action('woocommerce_after_cart_table'); ?> </form> <div class="cart-collaterals"> <?php do_action('woocommerce_cart_collaterals'); ?> <?php woocommerce_cart_totals(); ?> <?php woocommerce_shipping_calculator(); ?> </div> <?php do_action('woocommerce_after_cart');
/** * AJAX receive updated cart_totals div. */ public static function get_cart_totals() { if (!defined('WOOCOMMERCE_CART')) { define('WOOCOMMERCE_CART', true); } WC()->cart->calculate_totals(); woocommerce_cart_totals(); die; }
/** * AJAX receive updated cart_totals div. */ public static function get_cart_totals() { wc_maybe_define_constant('WOOCOMMERCE_CART', true); WC()->cart->calculate_totals(); woocommerce_cart_totals(); die; }
</div> <?php } ?> <input type="submit" class="button btn btn-default" name="update_cart" value="<?php _e( 'Update Cart', 'woocommerce' ); ?>" /> <?php do_action( 'woocommerce_cart_actions' ); ?> <?php wp_nonce_field( 'woocommerce-cart' ); ?> </td> </tr> <?php do_action( 'woocommerce_after_cart_contents' ); ?> </tbody> </table> <?php do_action( 'woocommerce_after_cart_table' ); ?> </form> <div class="cart-collaterals"> <?php do_action( 'woocommerce_cart_collaterals' ); ?> <?php woocommerce_cart_totals(); ?> </div> <?php do_action( 'woocommerce_after_cart' ); ?>