Auto-update Cart on Quantity Change

This snippet automatically updates the cart when the quantity of an item is changed, without requiring a manual update.

PHP

function auto_update_cart_on_quantity_change() {
    ?>
    <script type="text/javascript">
    jQuery(function($){
        $('form.woocommerce-cart-form').on('change', 'input.qty', function(){
            $("[name='update_cart']").trigger("click");
        });
    });
    </script>
    <?php
}
add_action( 'wp_footer', 'auto_update_cart_on_quantity_change' );

Snippet Feedback

Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY

15 Views

Tags

Language

Did it work?

Save Snippet

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.