Cart AJAX API
Definition
The Cart AJAX API is a set of storefront routes, /cart/add.js, /cart/change.js, /cart/update.js and /cart.js, that read and mutate the current cart and answer with JSON. Every Shopify storefront exposes them with no app and no access token. It is the mechanism behind any add-to-cart that doesn't reload the page.
Documented at shopify.dev, the Cart AJAX API.
How We've Used It
It's the transport under most of what we build around a cart. A grid card, a sticky bar, a bundle builder and a drawer all post to the same route, so we standardize the call rather than the button: paths read from Shopify's routes object, one add path every component shares, and section ids on the request so the drawer and the cart bubble come back rendered. Bundles ride it too, one line per component, picks attached as properties. The hard part is never the POST. It's everything else on the page that has to hear about it: loyalty widgets, installment messaging, analytics, a third-party drawer keeping its own copy of the cart.
Builds Using It
- Merchandisable featured-product carousel — LUS Brands. Every card in the rail adds without a page load.
- Shade-level collection grid — Nudestix. A grid whose unit is a shade, added from the card.
- Build-your-own palette bundle — Nudestix. One bundle line, with the shopper's picks attached.
- Bundle and kit PDP template — Nudestix. One add-to-bag, switching between a single line and a bundle post.
- Shade-selectable kit module on the PDP — Nudestix. Kits add every component in one request.
- Product card with per-variant payload — Nudestix. The grid card's quick add, on the same route as the PDP.
- WebMCP agent tools on a product page — Three Ships. The add-to-cart tool an agent can call, bounded to one item.
- 'Bundle and save' PDP block driven by a product-list metafield — LUS Brands
- Cart 'Add Ons' cross-sell driven by the Product Recommendations API — Nudestix
- Cart page rebuilt around loyalty points, protected gifts and a dark order summary — Nudestix
- Threshold-driven free shipping, deluxe sampling and a first-order gift notice — Nudestix
- Tabbed collection product slider and the shared merchandising card — Three Ships
- Featured-collection product card with metafield hero/hover media and a tag-driven badge stack — LUS Brands
- Featured tutorial with an adjacent shoppable product rail — Nudestix
- GA4 ecommerce dataLayer instrumentation across a Rebuy cart — Three Ships
- Size-pill variant picker and quick add-to-cart inside product grids — Three Ships
- Landing-page hero sections with a no-JS add-to-cart on page templates — Three Ships
- Mega-menu header with separate mobile menu and image blocks — Three Ships
- Mobile sticky add-to-cart bar mirrored from the real product form — LUS Brands
- Quiz results: a 34-rule, priority-ordered recommendation engine running client-side from metaobject data — LUS Brands
- Shoppable-video to cart bridge: Hue add-to-cart event wired into Rebuy's drawer — Three Ships
- Subscription bundle grid with tiered unlock progress — Three Ships
- Inline size picker on cart and PDP upsell cards — Three Ships
31 further gated builds use it; their pages follow.
Related Entities
- Line-item properties — what a composed bundle carries.
- Cart permalinks — the same job in a link, without scripts.
- Custom elements — what the components calling it are written as.
- localStorage — shopper-side state the cart shouldn't hold.