WooCommerce menu cart quantity update
-
I’m trying to create menu cart with quantity change option. Problem is when I use quantity change option and press button “Update cart”, I’m being redirected to cart page and quantity is not updated.
I’m using Avada theme and Ajax update works perfect for all fields when I add product into cart.
Here is code that I’m using:
<form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { ?> <?php $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); ?> <?php $item_name = method_exists( $_product, 'get_name' ) ? $_product->get_name() : $cart_item['data']->post->post_title; ?> <span class="fusion-menu-cart-item-title"><?php echo ($item_name); ?></span> <?php $product_quantity = woocommerce_quantity_input( array( 'input_name' => "cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), 'min_value' => '0', ), $_product, false ); ?> <?php echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); ?> <?php } ?> <input type="submit" class="button red" name="update_cart" value="Update cart" /> </form>
- The topic ‘WooCommerce menu cart quantity update’ is closed to new replies.