Repository Forums Support WooCommerce Extended Coupon Features PRO Free Product Label and Description Reply To: Free Product Label and Description

#11135
Soft79
Keymaster

You can add this snippet to functions.php:


/**
* Auto update cart after updating the quantity
*/
add_action( 'woocommerce_after_cart', function() {
    ?>
        <script>
            jQuery(function($) {
                var timeout;
                $('div.woocommerce').on('change textInput input', 'form.woocommerce-cart-form input', function(){
                    if(typeof timeout !== undefined) clearTimeout(timeout);

                    //Not if empty
                    if ($(this).val() == '') return;

                    timeout = setTimeout(function() {
                        $("[name='update_cart']").trigger("click"); 
                    }, 2000);
                }); 
            });
        </script>
    <?php
} );

This will update the cart after 2 seconds after an input value has changed.