How to update cart from shop page when product quantity increase/decrease in woocommerce?

Question

Here is the code I am using for updating my cart with ajax in CART page-

jQuery('div.woocommerce').on('change keyup mouseup', 'input.qty', function(){ // keyup and mouseup for Firefox support
    if (timeout != undefined) clearTimeout(timeout); //cancel previously scheduled event
    if (jQuery(this).val() == '') return; //qty empty, instead of removing item from cart, do nothing
    timeout = setTimeout(function() {
        jQuery('[name="update_cart"]').trigger('click');
    }, 1000 );
});

Its working fine , but my problem is when I try with same code in shop page its not updating my cart –
Here is what i have tried –

jQuery('li.product').on('change keyup mouseup', 'input.qty', function(){ // keyup and mouseup for Firefox support
    if (timeout != undefined) clearTimeout(timeout); //cancel previously scheduled event
    if (jQuery(this).val() == '') return; //qty empty, instead of removing item from cart, do nothing
    timeout = setTimeout(function() {
        jQuery('[name="update_cart"]').trigger('click');
    }, 1000 );
});

Here is the link if u want to check(https://cdn.royalancer.co.uk/test/).

0
, , , , Mahbub Ansary 12 months 0 Answers 56 views 0

Leave an answer