The bar shows how close the cart is to the threshold. That comes from cart.total_price (in cents) and the threshold. Nothing else to store.
Recompute it on every render. The width is the total as a percent of the threshold, capped at 100. The message is either how much is left or the unlocked state.
var remaining = THRESHOLD - cart.total_price;
var pct = Math.min(100, Math.round((cart.total_price / THRESHOLD) * 100));
barEl.style.width = pct + "%";
if (remaining <= 0) {
msgEl.textContent = "You've unlocked free shipping!";
barEl.classList.add("is-complete");
}
Don't keep a running `progress` total. Shopify can merge a line or apply a discount, and then your number lies. Derive from the cart, don't track.