Set Cart Items

Use the setItems mutation to set, or overwrite all cart items.

Mutation

setItems(input: SetCartItemsInput!): Cart!

ArgumentsType
inputSetCartItemsInput!

The setItems mutation will always return the Cart object.

SetCartItemsInput!

You can set all cart items at any time.

The setItems mutation will replace all existing items.

ArgumentTypeDescription
cartIdID!The id of the cart you are adding items to
items[SetCartItemInput!]!The same as AddToCartInput, just without cartId.

[SetCartItemInput!]!

ArgumentTypeDescription
idID!The id of the item you are adding.
nameStringGive items a name.
descriptionStringGive items a description.
typeCartItemType = SKUSKU (default), TAX, SHIPPING.
images[String]Any URLs to images for the item.
priceInt!The item price in cents.
quantityInt = 1Quantity of items to add.
attributes[CustomAttributeInput]key/value custom properties.

Example

mutation {
  setItems(
    input: {
      cartId: "ck5r8d5b500003f5o2aif0v2b"
      items: [
        {
          id: "5e3293a3462051"
          name: "Full Logo Tee"
          description: "Purple Triblend / L"
          images: ["full-logo-tee.png"]
          price: 2000
          quantity: 10
        }
        {
          id: "5e3293a3462051"
          name: "Cap"
          description: "Blue Cap / L"
          images: ["cap.png"]
          price: 1000
          quantity: 1
        }
      ]
    }
  ) {
    id
    totalItems
    items {
      id
      name
      lineTotal {
        amount
      }
    }
  }
}
{
  "data": {
    "setItems": {
      "id": "ck5r8d5b500003f5o2aif0v2b",
      "totalItems": 11,
      "items": [
        {
          "id": "ck5r8d5b500003f5o2aif0v2b",
          "name": "Full Logo Tee",
          "lineTotal": {
            "amount": 20000
          }
        },
        {
          "id": "ck5r8d5b500003f5o2aif0v2b",
          "name": "Cap",
          "lineTotal": {
            "amount": 1000
          }
        }
      ]
    }
  }
}