View Categories

Shortcode Doesn’t Update Amount on Shop/Product Pages

If the Free Shipping Bar: Amount Left for Free Shipping for WooCommerce shortcode shows the right amount on page load but not after items are added, turn on Enable AJAX (Pro) at WPFactory > Left for Free Shipping > Advanced. Without it, the shortcode is printed once and only changes when the page reloads.

Symptoms #

  • The shortcode on a shop, product or header area keeps the old amount after the customer adds or removes products.
  • It works correctly on the /cart/ page but not elsewhere.
  • Different visitors see the same amount, or an amount for an empty cart.

Cause #

[alg_wc_left_to_free_shipping] calculates the amount when the page is built. Adding to cart with AJAX does not rebuild the page, so the text stays as it was. With Enable AJAX on, Amount Left for Free Shipping wraps the shortcode output in an updatable element and fetches a fresh value each time WooCommerce fires a cart event such as added_to_cart, removed_from_cart or updated_cart_totals. If a caching plugin serves a saved copy of the page, the first value shown can also belong to another visitor’s cart.

Fix, step by step #

  1. Go to WPFactory > Left for Free Shipping (also reachable at WooCommerce > Settings > Amount Left for Free Shipping) and open Advanced.
  2. Under AJAX Options, tick Enable AJAX (Pro).
  3. If you use page caching, also tick Force update, which refreshes the amount on every page load.
  4. If your single product pages add to cart with a full page reload and the amount lags, tick Added to cart event without AJAX.
  5. Save changes, purge all caches (plugin, server and CDN), and test in a private window: add a product from the shop page and watch the text change.

Still not updating? #

  • You use the widget, not the shortcode: the Amount Left for Free Shipping widget is not refreshed by AJAX. Put the shortcode in a Shortcode or Text widget instead.
  • The shortcode has a min_free_shipping_amount attribute: the AJAX refresh does not pass that attribute on, so after an update the amount is calculated from the detected free shipping minimum. Set the threshold in Manual min amount and drop the attribute.
  • A custom theme or page builder cart: it may fire its own JavaScript event instead of WooCommerce’s. Add that event name to Additional events (space separated).
  • JavaScript errors: open the browser console on the page. An error from another script can stop the update request from running.
  • On the free version: there is no live update. Show the message on the cart page with the free Cart section, where WooCommerce redraws the totals, or accept that it updates on the next page load.

FAQ #

Does the shortcode update without Pro? #

No. The shortcode itself is free, but live updates come from the Pro AJAX option.

Where should I put the shortcode for a header message? #

Any header block, widget or template area works, as long as AJAX is enabled and the element is not inside a cached fragment that your cache plugin serves separately.

Does this also fix the cart page text? #

The Cart section is not refreshed by AJAX. If it lags on quantity changes, see Bar text does not update when the cart changes.

Related: Advanced and AJAX options and the shortcodes and widget reference.

Need a hand? Our team answers every ticket on the Amount Left for Free Shipping support forum.

 

Free Shipping Bar: Amount Left for Free Shipping for WooCommerce