Adds a merchandise line to the cart.


Anchor to cartId
cartId
required

The ID of the cart.

A list of merchandise lines to add to the cart.

The input must not contain more than 250 values.


Was this section helpful?

The updated cart.

The list of errors that occurred from executing the mutation.


Was this section helpful?
Hide code
Mutation reference
Copy
mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
  cartLinesAdd(cartId: $cartId, lines: $lines) {
    cart {
      # Cart fields
    }
    userErrors {
      field
      message
    }
  }
}
Hide code
Input
Copy
{
  "cartId": "gid://shopify/<objectName>/10079785100",
  "lines": [
    {
      "attributes": [
        {
          "key": "<your-key>",
          "value": "<your-value>"
        }
      ],
      "merchandiseId": "gid://shopify/<objectName>/10079785100",
      "quantity": 1,
      "sellingPlanId": "gid://shopify/<objectName>/10079785100"
    }
  ]
}
input CartLineInput {
  attributes: [AttributeInput!]
  merchandiseId: ID!
  quantity: Int
  sellingPlanId: ID
}

input AttributeInput {
  key: String!
  value: String!
}