i have small script should update cart count on page if product added or subtracted. not seem working when add cart item , quantity filed changed if refresh page:
(function($){ jquery(".hikashop_cart_module input.hikashop_product_quantity_field").change(function(){ var sum = 0; $(".hikashop_cart_module input.hikashop_product_quantity_field").each(function(){ sum += +$(this).val(); }).change(); $("#total").text(sum); }); })(jquery);
you have errors in code. compare one:
(function($){ // if load elements dynamically need use delegated events $(document).on('change', '.hikashop_cart_module input.hikashop_product_quantity_field', function(){ var sum = 0; $(this).each(function(){ sum += +$(this).val(); }); $("#total").text(sum); }); })(jquery);
Comments
Post a Comment