Mutations
Everything a storefront can write, which is the cart and two small things beside it.
Every cart mutation returns the whole cart, so a theme re-renders from the
payload rather than re-querying. A non-empty userErrors means nothing
changed; a non-empty warnings means something changed that the buyer did
not ask for.
cartCreate
Section titled “cartCreate”CartPayload!
Create a cart, optionally with lines already in it.
Called once per buyer session. Persist the returned id; do not create a cart on every page load.
| Argument | Type | Meaning |
|---|---|---|
input | CartInput | No description. |
cartLinesAdd
Section titled “cartLinesAdd”CartPayload!
Add lines.
Additive: adding a variant already in the cart increases that line rather than
making a second one. Because it is additive it is not safe to blind-retry
— a request that timed out may well have succeeded. On a retry, read the cart
and use cartLinesUpdate, which sets an absolute quantity.
Errors: NOT_FOUND for an unknown variant, UNAVAILABLE for an unpublished
one, INSUFFICIENT_STOCK with params.available, OUT_OF_RANGE past a
variant’s per-order limit.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
lines | [CartLineInput!]! | No description. |
cartLinesUpdate
Section titled “cartLinesUpdate”CartPayload!
Change lines.
Quantities are absolute. Safe to retry.
Errors: as cartLinesAdd, plus NOT_FOUND for a line id not in this cart.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
lines | [CartLineUpdateInput!]! | No description. |
cartLinesRemove
Section titled “cartLinesRemove”CartPayload!
Remove lines.
Removing a line that is already gone succeeds. Safe to retry.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
lineIds | [ID!]! | No description. |
cartNoteUpdate
Section titled “cartNoteUpdate”CartPayload!
Replace the buyer’s note. Null clears it.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
note | String | No description. |
cartAttributesUpdate
Section titled “cartAttributesUpdate”CartPayload!
Replace the cart’s attributes entirely.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
attributes | [AttributeInput!]! | No description. |
cartBuyerIdentityUpdate
Section titled “cartBuyerIdentityUpdate”CartPayload!
Set who is buying.
Merges: a member left out is left alone. Passing a customer access token attaches the cart to that account and fills in what the account knows.
Errors: INVALID for a malformed mobile number. EXPIRED for a customer
access token that is not a current session of this shop’s buyer — lapsed,
not good, or another shop’s; get a fresh one from the Customer Account API.
NOT_FOUND for a buyer this shop holds no customer for. A refused token
refuses the whole update: nothing else in it is written.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
buyerIdentity | CartBuyerIdentityInput! | No description. |
cartDiscountCodesUpdate
Section titled “cartDiscountCodesUpdate”CartPayload!
Replace the discount codes on the cart.
The whole set, not an addition — pass every code that should remain. A code
that does not apply is still recorded, with applicable: false, so the theme
can explain itself.
Errors: CODE_INVALID for one that does not exist or has lapsed. A real code
the cart does not qualify for is not an error; it comes back inapplicable.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
discountCodes | [String!]! | No description. |
cartDeliveryAddressUpdate
Section titled “cartDeliveryAddressUpdate”CartPayload!
Set where the cart is going.
Delivery options are recomputed against the new destination, which invalidates
any previous selection — expect a DELIVERY_OPTION_INVALIDATED warning and
ask the buyer again.
Errors: NOT_FOUND for an unknown province or city code, INCONSISTENT when
the city does not sit in the province, PATTERN for a malformed postal code.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
address | AddressInput | No description. |
cartDeliveryOptionsSelect
Section titled “cartDeliveryOptionsSelect”CartPayload!
Choose how each delivery group ships.
Errors: INVALID_STATE when there is no address yet, NOT_FOUND for a handle
not among that group’s current options.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
selections | [CartDeliveryOptionSelectionInput!]! | No description. |
cartInvoiceRequestUpdate
Section titled “cartInvoiceRequestUpdate”CartPayload!
Ask for, amend, or withdraw an official invoice — فاکتور رسمی.
Which fields are required depends on buyerType; a missing one comes back as
REQUIRED against its own path.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
invoiceRequest | InvoiceRequestInput! | No description. |
cartCheckoutStart
Section titled “cartCheckoutStart”CheckoutStartPayload!
Begin checkout: reserve stock, freeze the cart, and mint a handoff URL.
The last thing a theme does. After this the cart is read-only; mutating it releases the handoff and the buyer starts again.
idempotencyKey is required, and is why: a buyer on a dropping connection
taps “پرداخت” three times, and three handoffs would reserve stock three times
and could take payment twice. Generate a UUID when the button is first
pressed, hold it for the life of that attempt, and send the same one on every
retry. Replaying it with different arguments returns
IDEMPOTENCY_CONFLICT; replaying it identically returns the original handoff.
returnUrl must be on a domain of this shop. Hosted checkout appends the
order token to it.
Errors: INVALID_STATE, INSUFFICIENT_STOCK, UNAVAILABLE, EXPIRED.
| Argument | Type | Meaning |
|---|---|---|
cartId | ID! | No description. |
idempotencyKey | String! | No description. |
returnUrl | URL | No description. |
productReviewSubmit
Section titled “productReviewSubmit”ReviewSubmitPayload!
Submit a product review.
Moderated: the review comes back recorded but unpublished, and the theme must say so.
| Argument | Type | Meaning |
|---|---|---|
input | ReviewInput! | No description. |
marketingSubscriptionCreate
Section titled “marketingSubscriptionCreate”MarketingSubscriptionPayload!
Record marketing consent — a newsletter or SMS opt-in.
Deliberately unrevealing: an address that was already subscribed comes back accepted, because the alternative turns a footer form into a way to test which numbers are on a merchant’s list.
| Argument | Type | Meaning |
|---|---|---|
input | MarketingSubscriptionInput! | No description. |