Currently, I want to change the text inside a div after clicking a update_cart button on the cart page.
Now I use jQuery to trigger an action to make it work.
jQuery( document.body ).on( 'updated_cart_totals', function(){
var sum = 0;
jQuery(".qty").each(function(){
sum += +jQuery(this).val();
});
if(sum > 0 || sum != ''){
jQuery('#text_block-14-124, #text_block-179-47').text(sum);
}else{
jQuery('#text_block-14-124, #text_block-179-47').text('0'); // does not run
}
});
it works like charms, but when I change the quantity to 0 and click the update_cart button and make my cart empty, my script doesn't only run if there is a product on it. I can run a script to change text when clicking the update_cart button and then my cart empty.
I do not use cart fragments to make it works, completely manual code.