Skip to content
FunnelGuard

Fix guide by FunnelsGuard

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

PRF-243High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A shopper clicks add to cart. The product is added, or appears to be, but the cart count in the header stays at 0 or shows an old number. The mini cart drawer may also stay empty until the page is reloaded.

Most stores add items with a background request (called AJAX, a call the page makes without reloading). When the response comes back, the theme should update the badge. If that update fails, the cart and the badge disagree.

There are two different cases. In one, the item is in the cart and only the display is wrong. In the other, the add request failed and nothing was added. Both look the same to the shopper.

Why it costs you leads or sales

The cart count is the shopper's proof that the click worked. Without it, people click again and end up with duplicates, or decide the store is broken and leave. Others never find the cart because the badge gave no sign anything was added.

It can also hide a real failure. If the add request is failing, you lose sales and may also miss the add_to_cart event sent to GA4, Google Ads or Meta, which weakens your ad optimisation.

Where the journey breaks
  1. Product pageShopper views the product
  2. Add to cart clickButton is pressed
  3. Cart count updateBadge stays at 0
  4. Open cartShopper unsure it worked
  5. CheckoutNever reached

The product page works, but the feedback step fails, so later steps are lost.

Shoppers who reach checkoutExample numbers
Shoppers who reach checkout (example)Count updates: 60 %; Count stays at 0: 35 %023466035Count updatesCount stays at 0%

Example: illustrative numbers only, showing how a missing cart confirmation could reduce the share of shoppers who continue.

How to check if your site has it

Test it by hand
  1. Open a private window

    Use a fresh session with no logged-in user and no existing cart, on desktop and on a phone.

  2. Note the badge

    Look at the cart icon before you click. It should show 0 or no number.

  3. Add a product

    Click add to cart without reloading the page. Watch the badge and the mini cart.

  4. Open DevTools

    Press F12, open the Network tab, filter by Fetch/XHR and repeat. Look for the add request (for example /cart/add.js on Shopify, ?wc-ajax=add_to_cart on WooCommerce). A 4xx or 5xx status means the add itself failed.

  5. Reload the page

    If the badge is right only after a reload, the item was added and the display refresh is broken or cached.

How to fix it

First work out which case you have: the add request failed, or the badge did not refresh. Then use the steps for your platform.

Fix by platform
  1. Exclude cart pages and cookies from caching

    In your caching plugin, never cache /cart/, /checkout/ and /my-account/, and skip caching when the woocommerce_items_in_cart and woocommerce_cart_hash cookies are present.

  2. Check cart fragments

    WooCommerce refreshes the mini cart through the wc-ajax=get_refreshed_fragments request. If a performance plugin disables or delays cart fragments, turn that option off.

  3. Rule out conflicts

    Switch to a default theme or disable plugins one by one on a staging copy to find the one that breaks the update. Also check JavaScript minify, combine and delay settings.

Example: refresh the badge after add to cart (Shopify-style endpoints)javascript
async function addToCart(variantId) {
  const res = await fetch('/cart/add.js', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ items: [{ id: variantId, quantity: 1 }] })
  });
  if (!res.ok) { throw new Error('Add to cart failed: ' + res.status); }
  const cart = await (await fetch('/cart.js', { cache: 'no-store' })).json();
  document.querySelector('[data-cart-count]').textContent = cart.item_count;
}
Click works, update does not

The click is registered, but the step that should refresh the cart count never completes.

How to confirm it's fixed

Confirm the fix
  • In a private window, add a product and the badge changes immediately, without a reload
  • The mini cart or drawer shows the same item and quantity
  • The Network tab shows the add request returning a 200 status
  • Adding a second item raises the count again
  • Reloading the page keeps the same count
  • It works on mobile and on desktop, as a logged-out visitor

How to prevent it happening again

This usually breaks after a change: a theme update, a new app, a caching or speed plugin setting, or a CDN rule. Test add to cart after every one of those changes, on a staging copy first where you can.

Prevention habits
  • Keep cart, checkout and account pages out of page caches and CDN caches
  • Retest add to cart after theme, plugin or app updates
  • Avoid delaying or combining cart JavaScript in speed settings
  • Keep custom theme edits small and documented
  • Run an automated check on the add to cart journey on a schedule

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor runs your add to cart journey on a schedule, from the EU or the US, clicks the button and asserts the cart count: it checks that the number changes after the click. If it does not, the failure is re-checked from a second region, and then one alert goes out by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause.

Test traffic is marked (utm_source=funnelguard, fg_test=1, an fg_test cookie and its own user agent) and it stops before payment unless your store's test mode is set up. The Free plan covers 1 site and 2 journeys with daily checks and no card needed, and paid plans have a 3-day free trial.

Questions people ask

Why is my cart count not updating after add to cart?

The usual causes are a cached page or cart fragment, a failed add request, or theme JavaScript that does not refresh the badge. Open DevTools, watch the Network tab when you click, and check whether the add request succeeds. If it does and the badge only changes after a reload, the problem is the display refresh or caching.

Why does my WooCommerce cart icon show 0 until I refresh?

Often a caching or performance plugin is serving an old version of the header, or cart fragments (wc-ajax=get_refreshed_fragments) are disabled or delayed. Exclude cart pages and the WooCommerce cart cookies from caching, and turn off any setting that disables cart fragments.

Why is my Shopify cart count not updating?

A theme edit or an app, such as a cart drawer or upsell app, is often overriding the add to cart code. Test the default theme with apps disabled, then re-enable apps one at a time to find the one that breaks the cart bubble update.

How do I know if the product was actually added to the cart?

Reload the page or open the cart page. If the item is there, the add worked and only the badge is wrong. If it is missing, check the Network tab for a failed add request (a 4xx or 5xx status) and the Console for JavaScript errors.

Can caching cause the cart count to be wrong?

Yes. If a page cache or CDN stores the header with a cart count, shoppers may see someone else's old number or a stale zero. Cart, checkout and account pages, and any cart endpoint, should be excluded from caching or sent with no-store headers.

Does a cart count bug affect ad tracking?

It can be a sign the add request failed, which means add_to_cart events may not fire either. Even when the add works, check in GA4 DebugView or each platform's test tool that the event still fires.

How can I monitor the cart count automatically?

FunnelGuard runs your add to cart journey on a schedule with a robot visitor and asserts that the cart count changes after the click. If it does not, you get one alert with a screenshot and a likely cause after a second-region recheck.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: 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.