Shopify Storefront cart discount codes via cartDiscountCodesUpdate

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. Call cartDiscountCodesUpdate with the cart ID and a discountCodes array of strings representing the codes to apply.
  2. Read cart.discountCodes in the response to check the applicable field on each code—a code may be syntactically accepted but not applicable to current cart contents.
  3. Inspect cart.cost.totalAmount vs cart.cost.subtotalAmount to surface the discount amount to the buyer.
  4. To remove all discount codes, pass an empty array to cartDiscountCodesUpdate.
  5. Handle userErrors for codes that are completely invalid or expired at the time of the call.
  6. Note that automatic discounts are applied server-side without needing a code; manual codes and automatic discounts may interact—consult current Shopify docs for stacking rules.

Known gotchas

Related routes

Use the Shopify Storefront API to apply and remove discount codes on a cart via cartDiscountCodesUpdate and inspect allocations
shopify.dev · 6 steps · unrated
Shopify Storefront cart attributes and notes via cartAttributesUpdate and cartNoteUpdate
shopify.dev · 6 steps · unrated
Build a headless Shopify checkout flow using the Storefront API Cart and checkout redirect
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans