The dynamic header mini-cart widget is a core staple of modern e-commerce user experience. However, a common layout bug leaves users confused when the mini-cart counter freezes completely. A customer adds an item to their cart, a popup confirms the action, but the cart icon in the top navigation menu continues to display "0 items - $0.00." Even if they add more items, the widget refuses to update until they manually perform a hard refresh of the web page.
This glitch is caused by a failure in the wc-cart-fragments AJAX script execution flow. WooCommerce utilizes a native JavaScript routine to selectively update cart elements without reloading the document. If any third-party plugin or structural optimization script on your site throws a fatal JavaScript error anywhere on the page, browser script execution halts immediately. Because the script ecosystem crashes early, the AJAX response callback that carries your updated cart fragments data array never executes, leaving the frontend display permanently desynchronized from actual backend database sessions.
The Solution
Fixing the frozen element display requires debugging script execution orders and occasionally bypassing broken fragments logic.
-
Identify the Crashing Script: Open your storefront page, press F12 to load the Developer Tools, and review the Console panel. Trigger an "Add to Cart" action and check for red error lines. Identify the specific plugin script causing the crash and update or remove it.
-
Disable Aggressive JS Minification: Optimization plugins often break script execution orders by combinining files out of sequence. In your optimization plugin settings, exclude
wc-cart-fragments.jsandjquery.jsfrom deferred loading or script aggregation routines. -
Disable Fragments if Necessary: If your hosting setup experiences severe latency from frequent cart fragments AJAX hits, you can opt to disable the feature completely and force an immediate cart redirection via WooCommerce > Settings > Products > General. Tick Redirect to the cart page after successful addition, then inject this snippet to dequeue the asset block entirely:
add_action('wp_print_scripts', 'disable_woocommerce_cart_fragments', 100);
function disable_woocommerce_cart_fragments() {
wp_dequeue_script('wc-cart-fragments');
}
