On this page
What this issue is
A shopper clicks Add to cart. The item may or may not be added, but the small cart badge in the header still shows 0 (or the old number). The mini-cart drawer may also stay empty. The count only fixes itself after a manual page refresh, or never.
Most stores add items with AJAX, a background request that doesn't reload the page. After the request, theme JavaScript must redraw the count. If that redraw step fails, the shopper sees no change.
Why it costs you leads or sales
No visible feedback looks like a broken button. Shoppers click again and end up with duplicates, or leave because they think nothing happened. Others add the item, see 0 and never go to checkout. The impact is medium because the cart often still works, but trust and checkout starts drop.
- Product pageShopper clicks Add to cart
- Cart requestItem added in the background
- Cart countBadge still shows 0
- Cart pageShopper doesn't open it
- CheckoutNever reached
The item is added, but the count never redraws, so the shopper doesn't continue.
Example: illustrative numbers only. A visible count update keeps more shoppers moving to checkout.
How to check if your site has it
Open a product page in a private window
Use a fresh session with no cached cart. Note the number on the cart icon.
Click Add to cart
Watch the cart icon without refreshing. It should change within a second or two.
Open the browser console
Press F12, open Console and look for red errors after the click. Script errors often stop the redraw.
Check the Network tab
Find the add request (for example /cart/add.js on Shopify or ?wc-ajax=add_to_cart on WooCommerce). A 4xx or 5xx status means the add itself failed.
Refresh the page
If the count is correct only after refresh, the add worked and the redraw is broken.
Repeat on mobile and logged out
Caching and theme scripts often behave differently on phones and for guests.
The add request succeeds, but the script that redraws the count never runs.
How to fix it
Common causes: a page or CDN cache serving an old cart count, a JavaScript error from another app or plugin, a theme that doesn't re-read the cart after adding, or an add request that fails silently. Match the fix to what you saw in the console and Network tab.
Exclude cart pages and cookies from caching
In your cache plugin, never cache Cart, Checkout and My account, and bypass cache when the woocommerce_items_in_cart cookie is set.
Check cart fragments
WooCommerce refreshes the count through the wc-cart-fragments script. If an optimisation plugin removes or delays it, allow it again.
Test for plugin conflicts
Switch to a default theme and disable plugins one at a time until the count updates, then replace the culprit.
Check the theme setting
In WooCommerce settings, Products, make sure AJAX add to cart on archives is on if your shop pages use it.
Update the count from the cart
After add, the theme should fetch /cart.js and write cart.item_count to the badge. Compare with the theme's default (Dawn) to find what changed.
Use section rendering
Ask the add request to return the header section so the bubble is redrawn by the server, as modern themes do.
Disable recent apps
Apps that inject scripts can break the theme's cart code. Turn them off one at a time on a duplicate theme.
Update or roll back the theme
If it broke after a theme edit, compare versions in the code editor and restore the working one.
Look for tags that break scripts
In Preview mode, check Custom HTML tags that run on add-to-cart clicks. A tag that throws an error or replaces page elements can stop the count from redrawing.
Don't override cart elements
Remove any tag that rewrites the cart badge or the add button's click handler.
Check the cart settings
In Ecommerce settings, make sure the cart icon element is bound to the cart quantity and not a static text.
Remove conflicting custom code
Check Project settings, Custom code for scripts that hide or replace the cart icon, then republish.
Use the standard cart icon
Add the Cart Icon element from the Add panel so it updates automatically.
Review custom Velo code
If you use Velo, make sure code that changes the cart doesn't skip refreshing the cart icon.
Check the cart link
Use the built-in cart in the header. Custom cart links added with code don't show the live count.
Remove code injection conflicts
In Settings, Advanced, Code Injection, temporarily remove scripts and re-test.
Update the UI after a successful response
In the add handler, wait for the response, check it was OK, then read the new total and write it to the badge.
Send no-store headers for cart data
Cart endpoints and fragments must not be cached by the browser, server or CDN.
Catch errors
Show a message when the add fails so the shopper isn't left guessing.
async function addToCart(variantId, qty = 1) {
const res = await fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: variantId, quantity: qty })
});
if (!res.ok) {
alert('Could not add this item. Please try again.');
return;
}
const cart = await (await fetch('/cart.js', { cache: 'no-store' })).json();
document.querySelector('[data-cart-count]').textContent = cart.item_count;
}Broken
- Badge shows 0 after clicking Add to cart
- Correct number only after a page refresh
- Shoppers click twice and add duplicates
Fixed
- Badge updates within a second or two
- Count is fresh and never cached
- Failed adds show a clear message
How to confirm it's fixed
- In a private window, the badge changes right after clicking Add to cart
- No red errors appear in the console after the click
- The add request returns a 200 status
- The count is right on desktop and mobile
- The count stays right after moving to another page
- The mini-cart or cart page lists the same items as the badge
How to prevent it happening again
Most regressions come from theme edits, new apps or plugins, and cache changes. Test add to cart after each of those, on a staging copy if you have one.
| Change | Why it breaks the count | What to do |
|---|---|---|
| New cache or speed plugin | Serves an old cart count or delays cart scripts | Exclude cart data and re-test |
| New app or plugin | Throws a script error or overrides the add button | Disable it and re-test |
| Theme update or edit | Changes the badge selector or add handler | Compare with the default theme |
| Tag manager change | Custom HTML interferes with page elements | Check in Preview mode |
How FunnelGuard handles this
FunnelGuard detects this today. A robot visitor opens your product page on a schedule, clicks Add to cart and then asserts that the cart count has changed. If it hasn't, the step is marked as failed.
A failure is re-checked from a second region before one alert goes out (email, Slack, Teams, WhatsApp, webhook or PagerDuty) with a screenshot and a likely cause. The test visit is marked with utm_source=funnelguard, fg_test=1 and its own user agent, and it stops before payment. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.
Questions people ask
Why is my cart count not updating after I add an item?
Usually the add request worked but the script that redraws the badge failed or the count is cached. Check the browser console for errors, look at the add request in the Network tab, and exclude cart data from caching.
Why does my cart show 0 until I refresh the page?
The item is in the cart, but the page is showing a stale or cached count and not re-reading the cart after the add. Make the badge fetch fresh cart data after each add and exclude cart data from caches.
How do I fix WooCommerce cart count not updating?
Exclude Cart, Checkout and My account from page caching and bypass the cache when the cart cookie is set. Make sure your optimisation plugin isn't removing or delaying the wc-cart-fragments script, then test for plugin conflicts.
How do I fix Shopify cart count not updating?
Make sure the theme re-reads the cart (for example /cart.js) or re-renders the header section after adding. Compare your theme code with the default theme and disable recently added apps to find conflicts.
Can a caching plugin cause the cart count to be wrong?
Yes. If a cache stores the page with the cart count from another visitor or an earlier state, shoppers see the wrong number. Cart data should always bypass caching.
Does a cart count that doesn't update lose sales?
It can. Shoppers who see no change often think the button is broken, add the item again or leave. The effect is usually moderate because the cart itself may still work.
How can I test the cart count automatically?
A synthetic monitor can click Add to cart on a schedule and check that the count changes. FunnelGuard does this and alerts you with a screenshot if the count doesn't update.