/*wp_block_styles_on_demand_placeholder:69b2f1a817ef2*/ /*# sourceURL=wp-block-library-inline-css */

Automatically Update the WooCommerce Cart on Quantity Change

Today we have a quick Snippet for you that will allow you to have your cart totals update automatically as you change the quantity field without having to click the update button on the cart page.

Simply add these to Divi > Theme Options > Integrations tab, under the Body section.

WooCommerce Cart Page

If you are NOT using our custom quantity feature from Divi BodyCommerce, use the code below.

WooCommerce Cart Page with BodyCommerce custom quantity

If you are using WooCommerce with BodyCommerce you can do so much more. If you are using our custom quantity feature (form field customiser), use the code below.

12 Comments

  1. Thanks, works like a charm! I found this looking for a similar function for the single product page, using the Divi Woo Modules. Is there a similar code for that?

    Cheers,
    Nathan

    • That is a different ball game. Not so easy, sorry. If using BodyCommerce and our mini cart option – you can make this happen this way

      • Hi, how to use it on the mini cart?

        • Sorry this code is just for the cart page

  2. Thank you so much, worked! 🙂

    • Pleasure, glad to help 😀

  3. cool it work perfect, I added a delay, the cart update will wait a while for the customer to click multiple times

    var timeout;

    jQuery(document).ready(function ($) { // On jQeury load
    $(document).on(“click”, ‘.sub, .add’, function () { // When changing the custom “+” or “-”

    if ( timeout !== undefined ) {
    clearTimeout( timeout );
    }

    timeout = setTimeout(function() {

    $(“[name=’update_cart’]”).trigger(“click”);
    }, 5000 ); // 1 second delay, half a second (500) seems comfortable too// Update the cart
    });
    });

    • Nice one – appreciate it!

    • Thanks … exactly the script I needed!

  4. work perfect…great tutorial

Submit a Comment

Explore more from Divi Engine

Divi Form Builder

Divi Form Builder

From simple contact forms to complex frontend post or product creation, Divi Form Builder has you covered.

Divi Form Builder
Find out more
Divi Machine

Divi Machine

Build complex websites that displays dynamic fields you can filter, search and so much more with the Divi Builder.      

Divi Machine
Find out more
Divi BodyCommerce

Divi BodyCommerce

A versatile toolkit for developers using Divi and WooCommerce together, designed to boost your e-commerce site and achieve greater conversion rates.    

Divi BodyCommerce
Find out more
Divi Handoff

Divi Handoff

Let clients update content without touching the Divi Builder. Design layouts once, connect them to Flexible Content fields, and give editors simple forms for text, images, and sections.

Divi Handoff
Find out more
Divi Loop Extender

Divi Loop Extender

Unlock the Full Power of Divi 5 Loop Builder Add advanced sorting, filtering, and relationship logic right inside the Visual Builder.

Divi Loop Extender
Find out more
Divi Membership

Divi Membership

Monetize your Divi websites by transforming them into membership sites with seamless subscription management, user-friendly interfaces, and customizable membership tiers.

Divi Membership
Find out more
Divi Machine Accounts

Divi Machine Accounts

Build an account area for your customers to edit their details, access wishlist, submitted posts and more. *Note: Requires Divi Machine installed and active

Divi Machine Accounts
Find out more
Divi Ajax Filter

Divi Ajax Filter

Filter WooCommerce, Posts & Custom Posts without reloading the page.    

Divi Ajax Filter
Find out more
Divi Mobile

Divi Mobile

Divi Mobile helps you create beautiful looking mobile menus without having to code.

Divi Mobile
Find out more
Divi Nitro

Divi Nitro

Give your Divi website that extra boost of speed with our Divi Nitro plugin to enhance your customer's experience.

Divi Nitro
Find out more
Divi Protect

Divi Protect

Password protect the content of your Divi website with our Divi Protect plugin. Keep unwanted eyes out!

Divi Protect
Find out more
Divi Mega Menu

Divi Mega Menu

Create stunning, responsive, and content-rich mega menus using the Divi Builder you already know. No coding required.  

Divi Mega Menu
Find out more