Cart AJAX debugging - August 2026

Shopify Cart Not Updating Until Refresh: AJAX, Theme, and App Fixes (2026)

If your Shopify cart not updating until refresh issue shows up after quantity changes, add-to-cart clicks, or free gift logic, the cart data and visible cart HTML are out of sync.

~9 min read - AJAX cart, section rendering, cart count, app conflicts

Thunder Page Speed Optimizer can help with the performance side immediately: it defers non-critical scripts and reduces the JavaScript pressure around cart interactions. Use Thunder as the automated cleanup layer, then use this guide to fix the theme or app logic that controls the cart refresh.

Quick Fix with Thunder

Cart updates happen at a sensitive moment: the shopper has clicked, the theme posts to Shopify, apps may add gifts or discounts, and the UI has to update before trust drops. If third-party scripts block the main thread, shoppers may click twice, abandon the cart, or assume the store is broken.

Thunder's features handle script deferral, optimization, and Core Web Vitals improvements automatically. That will not repair a missing event listener, but it often removes the delay that hides otherwise working cart updates.

Install Thunder

First Prove Whether Cart Data or Cart UI Is Broken

Open DevTools, click Add to cart, and watch Network. If /cart/add.js or /cart/change.js returns a 200 response and /cart.js shows the correct item count, Shopify's cart data is fine. The broken piece is the visible UI: drawer HTML, cart count, line-item quantity, subtotal, or checkout button state.

If the request fails with a 400, 422, or redirect, debug the product form first. Variant IDs, selling plans, subscription apps, and bundle line-item properties can all make a cart request fail before the drawer has anything to refresh.

For related buying-path issues, use the cart drawer not opening guide, add-to-cart button checklist, and cart-to-checkout troubleshooting guide.

Fix AJAX Cart Updates with Section Rendering

Modern Shopify themes often fetch updated cart sections after a cart mutation. This keeps the drawer, subtotal, item list, and cart icon in sync without a full page reload. The exact section IDs differ by theme, so inspect your cart drawer and header sections before copying code.

async function changeCartQuantity(line, quantity) {
  const change = await fetch('/cart/change.js', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
    body: JSON.stringify({ line, quantity }),
  });

  if (!change.ok) throw new Error('Cart quantity update failed');

  const sections = ['cart-drawer', 'cart-icon-bubble'];
  const html = await fetch('/?sections=' + sections.join(',')).then((res) => res.json());

  document.querySelector('cart-drawer')?.replaceWith(
    new DOMParser().parseFromString(html['cart-drawer'], 'text/html').querySelector('cart-drawer')
  );

  document.querySelector('#cart-icon-bubble')?.replaceWith(
    new DOMParser().parseFromString(html['cart-icon-bubble'], 'text/html').querySelector('#cart-icon-bubble')
  );

  document.dispatchEvent(new CustomEvent('cart:updated'));
}

Do not assume those section IDs exist in your theme. Search your theme for cart-drawer, cart-icon-bubble, cart-items, and main-cart-items. Dawn-style themes have different refresh helpers than older custom themes.

Update the Cart Count, Subtotal, and Remove Buttons Together

A common partial fix updates the cart drawer line items but leaves the header count stale. Another common bug removes an item visually but keeps the old subtotal. Both make shoppers distrust checkout. Treat the cart as one stateful system, not separate widgets.

After every cart mutation, verify five elements: item rows, quantity inputs, cart count, subtotal, and checkout button disabled state. If any one of them still shows stale data, your refresh is incomplete.

SymptomLikely causeFix
Count updates only after refreshHeader section not refreshed.Replace cart icon section after /cart.js changes.
Quantity input jumps backTheme re-renders stale HTML.Fetch fresh cart sections after change.
Remove button does nothingLine index or key mismatch.Use the correct line item key or line number.
Free gift appears after reloadGift app updates cart after theme refresh.Wait for app cart mutation, then refresh sections.

Disable Cart Apps and Old Snippets in a Duplicate Theme

Cart problems often start after installing a bundle, free gift, upsell, subscription, or cart drawer app. The app may listen for one event name while your theme dispatches another. Or it may mutate the cart after your theme has already rendered fresh HTML.

Duplicate the theme, disable app embeds, and test a simple product. Then re-enable apps one by one. Start with cart, bundle, gift, subscription, popup, personalization, and page-builder apps. If the issue remains after uninstalling an app, run the Shopify app leftovers cleanup checklist.

Heavy app stacks also hurt responsiveness. The app scripts fix guide, Shopify INP guide, and complete Shopify speed optimization guide cover the speed side in more depth.

Manual Fix vs Thunder Fix

ProblemManual fixThunder fix
Broken cart refresh logicPatch AJAX events and section rendering.Not a logic replacement; keep manual patch.
Slow cart responseAudit and defer non-critical scripts by hand.Automatically improves script loading order.
App bloat around cartDisable, profile, and remove app leftovers.Reduces performance cost of remaining scripts.
Unclear before/afterTest PageSpeed, DevTools, and real devices.Pair with the speed test and app dashboards.

If the cart issue is tied to wider store performance, compare Thunder pricing with hands-on Shopify speed optimization.

FAQ

Why is my Shopify cart not updating until refresh?

Usually the add-to-cart or quantity request succeeds, but the theme does not refresh the cart drawer, cart count, or cart sections. Broken AJAX handlers, mismatched theme events, app conflicts, and cached section markup are common causes.

Why does the Shopify cart count stay wrong after adding a product?

The cart icon count often uses separate JavaScript from the cart drawer. If your code updates /cart.js but never replaces the count element, shoppers will see the old number until they refresh.

Can Shopify apps cause cart update issues?

Yes. Cart drawers, free gifts, bundles, upsells, subscriptions, page builders, and old app snippets can intercept cart requests or listen for different cart events.

Should I use /cart.js or section rendering to update the cart?

Use /cart.js for cart data and Shopify section rendering when you need fresh HTML for the drawer, cart items, or cart icon. Many Online Store 2.0 themes use both.

Can speed problems make the cart look broken?

Yes. Heavy JavaScript can delay quantity changes, drawer refreshes, and click feedback. Test the cart flow on mobile and measure INP, not only homepage load time.

Make cart updates feel instant again.

Thunder reduces script drag around high-intent cart actions while your theme handles the cart refresh logic correctly.