Skip to Content

CartDiscountCodesUpdatePayload

Payload returned by the cartDiscountCodesUpdate mutation. This object contains the updated cart after discount codes have been applied or modified, along with any errors that occurred during the update process.

Type Definition

type CartDiscountCodesUpdatePayload { cart: Cart! userErrors: [UserError]! }

Fields

FieldTypeDescriptionNullableRelationship
cartCart!The updated cart after discount codes updateNoReferences the Cart type
userErrors[UserError]!List of errors that occurred during the updateNoList of UserError objects

Relationships

  • cart: Links to the Cart object representing the current state of the shopping cart after discount codes have been updated.
  • userErrors: An array of UserError objects detailing any validation or processing errors encountered during the mutation.

Usage Examples

Basic Query

mutation { cartDiscountCodesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", discountCodes: ["SUMMER21"]) { cart { id discountCodes { code applicable } totalPrice } userErrors { field message } } }

Field Selection

{ cartDiscountCodesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", discountCodes: ["WELCOME10"]) { cart { id discountCodes { code } lineItems { id title quantity } } userErrors { message } } }

Nested Queries

{ cartDiscountCodesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", discountCodes: ["FREESHIP"]) { cart { id lineItems { id title variant { id price sku } } discountCodes { code applicable } } userErrors { field message } } }

Filtering and Sorting

Note: This payload type itself does not support filtering or sorting directly. Filtering and sorting can be applied on nested fields such as cart.lineItems if supported by the Cart type.

Implements

This type does not implement any interfaces.

Connections

No connection fields are defined on this type.

  • Cart: Represents the shopping cart object, including items, discounts, and pricing.
  • UserError: Represents errors related to user input or processing during mutations.

Best Practices

  • Always check the userErrors array after performing the cartDiscountCodesUpdate mutation to handle any issues gracefully.
  • Use the updated cart object returned in the payload to refresh UI state and reflect the latest cart totals and discount applications.
  • When applying discount codes, ensure codes are valid and applicable to the current cart to avoid errors.
  • Use pagination, filtering, and sorting on nested cart fields like lineItems where supported to optimize data retrieval.

Notes

  • The cart field is guaranteed to be non-null and represents the authoritative state of the cart after discount code updates.
  • The userErrors field provides detailed feedback for invalid discount codes or other update issues.
  • This API currently requires no authentication; however, this may change in future versions.
  • To optimize performance, request only the fields you need from the cart object.
  • Handling errors proactively by inspecting userErrors helps improve user experience during checkout flows.
Last updated on