Answer the question
In order to leave comments, you need to log in
WooCommerce how to auto refresh without a button?
In WooCommerce, you can change the number of products in the cart, I need to do the same, but in the modal window when adding.
I collected something from what I took in the basket, it turned out the following.
<form class="woocommerce-cart-form" action="<?php echo esc_url(wc_get_cart_url()); ?>" method="post">
<div class="shop_table_responsive cart woocommerce-cart-form__contents">
<?php
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
if($cart_item['data']->get_id() == $product->id)
{
$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); ?>
<div class="row cart_product_row woocommerce-cart-form__cart-item <?php echo esc_attr(apply_filters('woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key)); ?>">
<div class="product-quantity" data-title="<?php esc_attr_e('Quantity', 'woocommerce'); ?>">
<?php
if ($_product->is_sold_individually()) {
$product_quantity = sprintf('1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key);
} else {
echo '<div class = "on_small" style="font-size: 14px; color: #b0b0b0; margin-bottom: 10px; font-weight: 400;">Количество</div >';
$product_quantity = woocommerce_quantity_input(
array(
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
),
$_product,
false
);
}
echo apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item); // PHPCS: XSS ok.
}
}
?>
</div>
</div>
<div class="row cart_product_row coupon_row">
<div class="col-12">
<button type="submit" class="button green_btn mt-5" name="update_cart" value="<?php esc_attr_e('Update cart', 'woocommerce'); ?>"><?php esc_html_e('Update cart', 'woocommerce'); ?></button>
<?php wp_nonce_field('woocommerce-cart', 'woocommerce-cart-nonce'); ?>
</div>
</div>
</div>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question