Update Cart

Use the updateCart mutation to delete a cart, and all items associated to it.

Mutation

updateCart(input: UpdateCartInput!): Cart!

ArgumentsType
inputUpdateCartInput!

The updateCart mutation will always return the updated Cart.

UpdateCartInput!

ArgumentTypeDescription
idID!The id of the Cart you want to update.
currencyCurrencyInputUpdate the cart currency.
emailStringUpdate the email associated with the cart.
notesStringLet customer save notes for the cart.
attributesCustomAttributeInputCustom key/value attributes array for the cart.

If no cart item exists with the id provided, an error will be returned.

CustomAttributeInput

It is often useful to save user specific state in the cart for UI, or checkout purposes. You update the cart to include an array of custom attributes.

FieldTypeDescription
keyString!Custom attributes must have a key.
valueStringThe value of your custom attribute.

Example

mutation {
  updateCart(
    input: {
      id: "ck5r8d5b500003f5o2aif0v2b"
      currency: { code: USD }
      email: "hi@cartql.com"
      notes: "These are my order notes"
      attributes: [
        { key: "subscribeToUpdates", value: "hi@cartql.com" }
        { key: "referredBy", value: "@notrab" }
      ]
    }
  ) {
    id
    currency {
      code
    }
    email
    notes
    attributes {
      key
      value
    }
  }
}
{
  "data": {
    "updateCart": {
      "id": "ck5r8d5b500003f5o2aif0v2b",
      "currency": {
        "code": "USD"
      },
      "email": "hi@cartql.com",
      "notes": "These are my order notes",
      "attributes": [
        {
          "key": "subscribeToUpdates",
          "value": "hi@cartql.com"
        },
        {
          "key": "referredBy",
          "value": "@notrab"
        }
      ]
    }
  }
}