当woocommerce中产品数量增加/减少时,如何从商店页面更新购物车?

这是我用来在CART页面中用ajax更新购物车的代码-

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 );
});

它工作正常,但是我的问题是,当我在商店页面中尝试相同的代码时,它没有更新我的购物车- 这是我尝试过的-

jQuery('li.product').on('change keyup mouseup',1000 );
});

如果您要检查(https://cdn.royalancer.co.uk/test/),这是链接。

WOJIAXIAOMIAN3 回答:当woocommerce中产品数量增加/减少时,如何从商店页面更新购物车?

您可以这样使用

jQuery('li.product').on('change keyup mouseup','button.plus.qib-button,button.minus.qib-button',function(){ // keyup and mouseup for Firefox support
   var timeout;
   var this_ = jQuery(this);
       timeout = setTimeout(function() {
       this_.parent().parent().find('.ajax_add_to_cart').trigger( 'click' );
       clearTimeout(timeout);
    },1000 );
});
本文链接:https://www.f2er.com/3164970.html

大家都在问