Problem Description #
Customer clicks the coupon URL, the coupon seems to be applied (or cookie present), but the cart totals and displayed prices do not reflect the discount until a manual page refresh or further action.
Symptoms #
- Coupon shows in cookie or in applied coupons list but totals remain unchanged.
- AJAX cart fragments fail to refresh; single-page carts don’t show changes.
Typical cause #
Theme or plugin does not refresh WooCommerce cart fragments or Ajax/cart-update calls are blocked by caching, resulting in stale cart HTML being displayed. Block editor/checkout/cart blocks and page builders may also require different hooks.
Solution-step-by-step #
- Reproduce the issue
- Open a clean browser or incognito window.
- Visit the coupon URL and then go to the cart page. Note whether the totals show the discount.
- Open a clean browser or incognito window.
- Force reload / refresh cart fragments
- As a short test, manually refresh the cart page (F5). If totals update after refresh, the issue is almost certainly a cart-fragment / caching problem.
- As a short test, manually refresh the cart page (F5). If totals update after refresh, the issue is almost certainly a cart-fragment / caching problem.
- Check for caching of cart fragments
- Ensure your cache plugin or CDN doesn’t cache dynamic cart fragments. For many caching solutions, you should exclude ? queries or /cart, /checkout pages from cache.
- Purge cache and test again. WordPress.org
- Ensure your cache plugin or CDN doesn’t cache dynamic cart fragments. For many caching solutions, you should exclude ? queries or /cart, /checkout pages from cache.
- Disable/minimize scripts that prevent Ajax
- Some performance plugins defer or delay JavaScript; this can block the cart fragment refresh. Disable JS deferral for frontend/cart scripts and test.
- If you use asset optimization, disable it for WooCommerce scripts temporarily.
- Some performance plugins defer or delay JavaScript; this can block the cart fragment refresh. Disable JS deferral for frontend/cart scripts and test.
- Test theme and plugin conflicts
- Switch to a default theme and deactivate other plugins except WooCommerce and coupon plugin. If it works, re-enable components to isolate the conflict. WordPress.org
- Switch to a default theme and deactivate other plugins except WooCommerce and coupon plugin. If it works, re-enable components to isolate the conflict. WordPress.org
- Apply a manual “refresh cart” snippet (if needed)
- If your theme does not trigger cart fragment updates, add a small JS snippet to force refresh the cart after the coupon is applied (requires developer / theme edits):
- If your theme does not trigger cart fragment updates, add a small JS snippet to force refresh the cart after the coupon is applied (requires developer / theme edits):
jQuery( function($){
// After coupon applied event – this example fires after the plugin sets cookie or queue
$(document).on(‘coupon_applied_event’, function(){
// request cart fragments update
$.ajax({
url: wc_cart_fragments_params.ajax_url,
type: ‘POST’,
data: { action: ‘woocommerce_get_refreshed_fragments’ }
}).done( function(response){
if ( response && response.fragments ) {
$.each(response.fragments, function(key, val){
$(key).replaceWith(val);
});
}
});
});
});
-
- Important: Use the plugin’s actual event name or trigger the refresh after the code that sets the cookie — you may need a developer to adapt this snippet. (Use safely in a child theme or custom plugin.)
- Important: Use the plugin’s actual event name or trigger the refresh after the code that sets the cookie — you may need a developer to adapt this snippet. (Use safely in a child theme or custom plugin.)
- Consider redirecting to cart page after applying coupon
- If the plugin supports a redirect to cart after applying the coupon, enable it in plugin settings so the cart page loads with fresh totals (less reliance on fragments). WPFactory
- If the plugin supports a redirect to cart after applying the coupon, enable it in plugin settings so the cart page loads with fresh totals (less reliance on fragments). WPFactory
Prerequisites #
- Working WooCommerce AJAX setup (no blocked admin-ajax).
- If using optimization plugins, be able to exclude WooCommerce scripts.
Additional notes #
- The robust long-term fix is to ensure cart fragments are supported and not cached and to avoid deferring core WooCommerce JS.
For block-based carts, ensure plugin supports WooCommerce Blocks or provide a custom handler.
