Skip to content

Change the quantity of a cart line

PUT
/stores/{storeRef}/cart/items/{itemId}
curl --request PUT \
--url https://apibase.ecomweb.app/api/v1/stores/example/cart/items/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-storefront-api-key: <x-storefront-api-key>' \
--data '{ "quantity": 3 }'

Sets the quantity of the line identified by itemId. A quantity of 0 or less removes the line and the response then carries item: null. The body is not validated up front: a missing or invalid quantity is not rejected with a 400. The request fails with a server error when the shopper has no cart yet.

itemId
required
string

The cart line ID, as returned in the cart’s items[].id or when the line was added.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
quantity
required

The new quantity. A quantity of 0 or less removes the line.

number

Example

3
Media typeapplication/json
object
item
required

The line after the change, or null when the quantity was 0 or less and the line was removed.

object
id

Cart line ID.

string
cart_id

ID of the cart the line belongs to.

string
product_id
required

ID of the product.

number
variant_id

ID of the variant, or null when the line has none.

number
nullable
quantity
required

Units in the line.

number
created_at

When the line was added, as an ISO 8601 timestamp.

string
updated_at

When the line last changed, as an ISO 8601 timestamp.

string
cart_id
required

ID of the cart.

string

Example generated

{
"item": {
"id": "example",
"cart_id": "example",
"product_id": 1,
"variant_id": 1,
"quantity": 1,
"created_at": "example",
"updated_at": "example"
},
"cart_id": "example"
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}