CartLinesRemovePayload
Payload returned by the cartLinesRemove mutation. This object provides the updated state of the cart after removing specified lines, along with any errors encountered during the operation.
Type Definition
type CartLinesRemovePayload {
cart: Cart!
userErrors: [UserError]!
}Fields
| Field | Type | Nullability | Description | Relationship |
|---|---|---|---|---|
cart | Cart | Non-nullable | The updated cart after removing lines | References Cart type |
userErrors | [UserError] | Non-nullable | List of errors that occurred during removal | List of UserError objects |
Relationships
- cart: This field returns the updated
Cartobject reflecting the current state after the removal of lines. - userErrors: This field returns a list of
UserErrorobjects that describe any issues encountered during the removal process, such as invalid line IDs or permission errors.
Usage Examples
Basic Query
mutation {
cartLinesRemove(cartId: "eyJhbGciOiJIUzI1NiJ9...", lineIds: [123, 456]) {
cart {
id
totalQuantity
}
userErrors {
field
message
}
}
}Field Selection
mutation {
cartLinesRemove(cartId: "eyJhbGciOiJIUzI1NiJ9...", lineIds: [789]) {
cart {
id
lines {
id
quantity
merchandise {
... on ProductVariant {
id
title
price
}
}
}
estimatedCost {
totalAmount {
amount
currencyCode
}
}
}
userErrors {
message
}
}
}Nested Queries
mutation {
cartLinesRemove(cartId: "eyJhbGciOiJIUzI1NiJ9...", lineIds: [101112]) {
cart {
id
lines {
id
quantity
merchandise {
... on ProductVariant {
product {
id
title
vendor
}
}
}
}
}
userErrors {
field
message
}
}
}Filtering and Sorting
The CartLinesRemovePayload type itself does not support filtering or sorting directly. However, you can filter or sort the cart lines in the cart object after retrieval using client-side logic or by querying the cart.lines connection with appropriate arguments if supported.
Implements
This type does not implement any interfaces.
Connections
No direct connections are defined on this type.
Related Types
- Cart: Represents the shopping cart object, including its lines, quantities, and pricing.
- UserError: Represents errors encountered during mutations or queries, including fields and messages describing the problem.
Best Practices
- Always check the
userErrorsarray after performing thecartLinesRemovemutation to handle any issues gracefully. - Use the returned
cartobject to update the client-side cart state to reflect the latest changes. - When removing multiple lines, batch the
lineIdsto minimize network requests. - Handle cases where the cart may be empty after line removal to update UI accordingly.
Notes
- The
cartfield is guaranteed to be non-null and represents the cart’s current state after the mutation. - The
userErrorsfield provides detailed error information but will be an empty list if the operation succeeds without issues. - This API currently requires no authentication; however, this may change in future versions.
- For performance, avoid requesting deeply nested fields unless necessary, as this can increase response size and latency.
- The
cartLinesRemovemutation is idempotent for the samelineIdsandcartIdcombination, but always verify the returnedcartstate.
Last updated on