You are currently viewing Update cart on quantity change automatically in Woocommerce

Update cart on quantity change automatically in Woocommerce

Woocommerce cart provide cart update after clicking “Update Cart” button. To update quantity in cart you have click on update cart button always. Sometimes it’s required to update cart quantity by changing cart quantity and remove “Update Cart” buttob too. Using below CSS and jQuery code and remove “Update Cart” button and change quantity on changing input qunatity.

Hide the WooCommerce “Update Cart” Button with CSS

input[name='update_cart'] {
     display: none !important;
button[name='update_cart'] {
    display: none !important;

Now “Update Cart” button is hidden and use below code to update cart on quantity change.

Auto-update WooCommerce Cart when Quantity Changes with PHP and jQuery

Now that the button is hidden, all we need to do is to “click” the button via JQuery and let WooCommerce do the exact same job like Update Cart button click (updating cart totals, taxes, etc.).

In detail, when we “click” on any of the quantity inputs, we go and trigger a “click” on the hidden Update Cart button and update quantity of cart page.

//Cart Ajax quantity update
add_action( 'wp_footer', 'woocommerce_cart_change_update_qty' ); 
function woocommerce_cart_change_update_qty() { 
   // Check current page is cart page
   if (is_cart()) { 
      <script type="text/javascript"> 
         jQuery('div.woocommerce').on('click', 'input.qty', function(){ 

Leave a Reply