0

I am using AJAX to autoupdate Cart in WooCommerce, and I use code from this article (as shown below): Auto update cart after quantity change and it works well for the Cart amount. However, the Mini-cart in the header is not updating. Can you please suggest changes to the code to update both the main Cart and the Mini-cart in the same iteration?

The code I use to auto-update Cart:

 
function cart_update() { 
    if (is_cart()) { ?> 
            <script type="text/javascript"> 
                var timeout;
            jQuery('div.woocommerce').on('change', 'input.qty', function(){ 
                if(timeout != undefined){
                  clearTimeout(timeout);
                }
                timeout = setTimeout(function() {
                  jQuery("[name='update_cart']").trigger("click"); 
                }, 1000);
            }); 
        </script> 
        <?php 
    } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.