Skip to content

cartLineItemsAdd

Mutationin Cart

Add line items to cart or create a new cart

Arguments

ArgumentTypeDescription
idID
versionString
lineItems[CartLineItemAddInput!]!

Returns

CartLineItemsAddResponse!

FieldTypeDescription
cartCartCart information after line items are added
lineResults[CartLineItemAddResult!]One result per requested line, in the order requested: added, or why not. Lines that can be added are added even when others cannot. Null when the request failed as a whole, which cartErrors then says.
addedQuantityIntHow many items were added in total, counted by quantity.
addedAmountMoneyWhat the added lines add to the cart total. Null when the request failed as a whole.
cartErrors[CartLineItemsAddError!]Error details if line item addition failed

Example

mutation CartLineItemsAdd(
$id: ID
$version: String
$lineItems: [CartLineItemAddInput!]!
) {
cartLineItemsAdd(id: $id, version: $version, lineItems: $lineItems) {
cart {
id
version
createdAt
lastModifiedAt
currency
customerEmail
isGuest
totalQuantity
deliveryRemarks
vatNumber
purchaseOrderNumber
deliverySplit
requestedDeliveryDate
earliestCompleteDeliveryDate
name
defaultName
status
}
lineResults {
sku
quantity
failure
message
}
addedQuantity
addedAmount {
centAmount
currency
}
cartErrors {
__typename
... on ValidationError {
message
}
... on CartError {
message
code
}
}
}
}

The query selects the return type's fields two levels deep; pick the ones you need. The response shows its shape with placeholder values.

Served by

@evolve-framework/commercetoolsResolved
@evolve-framework/medusaResolved
@evolve-framework/sfccResolved

Used by

The storefront packages that send it, in these GraphQL documents: