Shopify Ajax API (/cart.js) does not update cart state immediately after add/change requests.

Short description of issue

Shopify Ajax API (/cart.js) does not update cart state immediately after add/change requests.

Reproduction steps

  1. Open an Online Store storefront (no checkout).
  2. Add a product to cart using POST /cart/add.js.
  3. Immediately request GET /cart.js after the add request resolves.
  4. Observe that /cart.js sometimes returns stale data:
    • item_count is still 1
    • items array does not include the newly added item
  5. A subsequent /cart.js request (after a short delay) returns correct data.

Additional info

It happens currently

What type of topic is this

Bug report

Upload screenshot(s) of issue



Hi @Yasuo

What theme are you using here? Can you share the store URL too so we can investigate?

1 Like

I can’t share my store’s URL, but I found the solution.
Before calling /add.js, I first call /update.js with an empty payload and wait for it to complete.
After that, everything works as expected — /cart.js is updated with the latest data.
However, this workaround makes the UI render slower.

Thank you for your response. @Liam-Shopify

1 Like