Skip to Content

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

FieldTypeNullabilityDescriptionRelationship
cartCartNon-nullableThe updated cart after removing linesReferences Cart type
userErrors[UserError]Non-nullableList of errors that occurred during removalList of UserError objects

Relationships

  • cart: This field returns the updated Cart object reflecting the current state after the removal of lines.
  • userErrors: This field returns a list of UserError objects 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.

  • 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 userErrors array after performing the cartLinesRemove mutation to handle any issues gracefully.
  • Use the returned cart object to update the client-side cart state to reflect the latest changes.
  • When removing multiple lines, batch the lineIds to minimize network requests.
  • Handle cases where the cart may be empty after line removal to update UI accordingly.

Notes

  • The cart field is guaranteed to be non-null and represents the cart’s current state after the mutation.
  • The userErrors field 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 cartLinesRemove mutation is idempotent for the same lineIds and cartId combination, but always verify the returned cart state.
Last updated on