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
| Field | Type | Description | Nullable | Relationship |
|---|---|---|---|---|
cart | Cart! | The updated cart after discount codes update | No | References the Cart type |
userErrors | [UserError]! | List of errors that occurred during the update | No | List of UserError objects |
Relationships
- cart: Links to the
Cartobject representing the current state of the shopping cart after discount codes have been updated. - userErrors: An array of
UserErrorobjects 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.
Related Types
- 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
userErrorsarray after performing thecartDiscountCodesUpdatemutation to handle any issues gracefully. - Use the updated
cartobject 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
cartfields likelineItemswhere supported to optimize data retrieval.
Notes
- The
cartfield is guaranteed to be non-null and represents the authoritative state of the cart after discount code updates. - The
userErrorsfield 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
cartobject. - Handling errors proactively by inspecting
userErrorshelps improve user experience during checkout flows.
Last updated on