Add Item
Use the addItem mutation to add new items to the cart.
Mutation
addItem(input: AddToCartInput!): Cart!AddToCartInput
| Argument | Type | Description |
|---|---|---|
cartId | ID! | The id of the cart you are adding items to |
id | ID! | The id of the item you are adding |
name | String | Give items a name |
description | String | Give items a description |
type | CartItemType | SKU (default), TAX, or SHIPPING |
images | [String] | Any URLs to images for the item |
price | Int! | The item price in cents |
quantity | Int | Quantity of items to add (default: 1) |
metadata | Json | Custom meta object for the cart |
Example
mutation {
addItem(
input: {
cartId: "ck5r8d5b500003f5o2aif0v2b"
id: "5e3293a3462051"
name: "Full Logo Tee"
description: "Purple Triblend / L"
price: 2000
quantity: 10
}
) {
id
totalItems
subTotal {
formatted
}
items {
id
name
quantity
}
}
}