Skip to content
Select theme
Light
Dark
Auto
Select language
English
فارسی

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.

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.

ArgumentTypeMeaning
inputCartInputNo description.

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.

ArgumentTypeMeaning
cartIdID!No description.
lines[CartLineInput!]!No description.

CartPayload!

Change lines.

Quantities are absolute. Safe to retry.

Errors: as cartLinesAdd, plus NOT_FOUND for a line id not in this cart.

ArgumentTypeMeaning
cartIdID!No description.
lines[CartLineUpdateInput!]!No description.

CartPayload!

Remove lines.

Removing a line that is already gone succeeds. Safe to retry.

ArgumentTypeMeaning
cartIdID!No description.
lineIds[ID!]!No description.

CartPayload!

Replace the buyer’s note. Null clears it.

ArgumentTypeMeaning
cartIdID!No description.
noteStringNo description.

CartPayload!

Replace the cart’s attributes entirely.

ArgumentTypeMeaning
cartIdID!No description.
attributes[AttributeInput!]!No description.

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.

ArgumentTypeMeaning
cartIdID!No description.
buyerIdentityCartBuyerIdentityInput!No description.

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.

ArgumentTypeMeaning
cartIdID!No description.
discountCodes[String!]!No description.

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.

ArgumentTypeMeaning
cartIdID!No description.
addressAddressInputNo description.

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.

ArgumentTypeMeaning
cartIdID!No description.
selections[CartDeliveryOptionSelectionInput!]!No description.

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.

ArgumentTypeMeaning
cartIdID!No description.
invoiceRequestInvoiceRequestInput!No description.

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.

ArgumentTypeMeaning
cartIdID!No description.
idempotencyKeyString!No description.
returnUrlURLNo description.

ReviewSubmitPayload!

Submit a product review.

Moderated: the review comes back recorded but unpublished, and the theme must say so.

ArgumentTypeMeaning
inputReviewInput!No description.

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.

ArgumentTypeMeaning
inputMarketingSubscriptionInput!No description.