Streaming live at 10am (PST)

Ecommerce Cart items countdown update tweak

Hi,

I’m trying to get an item countdown to work with the ecommerce shopping cart. The end game would be to create something like a “cart fill” bar in the shopping cart to show you how close your are from having free shipping for instance.

The code I have written now is :

$('.w-commerce-commercecartquantity').change(function(){
    setTimeout(function(){     
var beerQty = $('.w-commerce-commercecartopenlinkcount').text();
    var leftQty = 12 - beerQty ;
	    console.log('beers missing' + ' ' + leftQty);
    $(".beers-left").text(leftQty);
}, 500);
});

It takes the number of items in cart and substracts it to 12 (the number of beer bottles you need to ship a box in this case) and shows you how many bottles are missing. It works fine for the first time, but when you update more than once the quantity field in your shopping cart it stops working… any idea why ?

Has anyone made it to using the shopping cart qty in other scripts ? With the updates working ? @Diarmuid_Sexton maybe ?

Thanks :slight_smile:

[UPDATE] Found a nice solution and will post a clean Tips & Tutorial on the forum for others wanting similar results