Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Cart count not updating after add to cart: how to fix it

CNV-152Medium impactDetectedBy FunnelGuardPublished Updated
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.

Where the journey breaks
  1. Product pageShopper clicks Add to cart
  2. Cart requestItem added in the background
  3. Cart countBadge still shows 0
  4. Cart pageShopper doesn't open it
  5. CheckoutNever reached

The item is added, but the count never redraws, so the shopper doesn't continue.

Shoppers reaching checkoutExample numbers
Shoppers reaching checkout (example)Count updates: 60 per 100 add-to-cart clicks; Count stuck at 0: 38 per 100 add-to-cart clicks023466038Count updatesCount stuck at 0per 100 add-to-cart clicks

Example: illustrative numbers only. A visible count update keeps more shoppers moving to checkout.

How to check if your site has it

Test it by hand
  1. Open a product page in a private window

    Use a fresh session with no cached cart. Note the number on the cart icon.

  2. Click Add to cart

    Watch the cart icon without refreshing. It should change within a second or two.

  3. Open the browser console

    Press F12, open Console and look for red errors after the click. Script errors often stop the redraw.

  4. 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.

  5. Refresh the page

    If the count is correct only after refresh, the add worked and the redraw is broken.

  6. Repeat on mobile and logged out

    Caching and theme scripts often behave differently on phones and for guests.

The click works, the update doesn't

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.

Fix by platform
  1. 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.

  2. Check cart fragments

    WooCommerce refreshes the count through the wc-cart-fragments script. If an optimisation plugin removes or delays it, allow it again.

  3. Test for plugin conflicts

    Switch to a default theme and disable plugins one at a time until the count updates, then replace the culprit.

  4. Check the theme setting

    In WooCommerce settings, Products, make sure AJAX add to cart on archives is on if your shop pages use it.

Generic add-to-cart handler that refreshes the badgejavascript
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;
}
Cart badge behaviour

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

Confirmation checklist
  • 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.

Changes that commonly break the cart count
ChangeWhy it breaks the countWhat to do
New cache or speed pluginServes an old cart count or delays cart scriptsExclude cart data and re-test
New app or pluginThrows a script error or overrides the add buttonDisable it and re-test
Theme update or editChanges the badge selector or add handlerCompare with the default theme
Tag manager changeCustom HTML interferes with page elementsCheck 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.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: click + assert cart count.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.