Update Cart Item
Update the quantity or attributes of an item in the shopping cart.
Endpoint
PUT /api/shop/cart/items/{itemId}Request Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | application/json |
X-STOREFRONT-KEY | Yes | Your storefront API key |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
itemId | integer | Yes | Cart item ID |
Request Body
json
{
"quantity": 5,
"attributes": {
"color": "Red",
"size": "Medium"
}
}| Field | Type | Required | Description |
|---|---|---|---|
quantity | integer | No | New quantity |
attributes | object | No | Updated attributes |
Response Fields (200 OK)
| Field | Type | Description |
|---|---|---|
id | integer | Cart item ID |
productId | integer | Product ID |
productName | string | Product name |
quantity | integer | Updated quantity |
price | decimal | Unit price |
subtotal | decimal | Updated line total |
attributes | object | Updated attributes |
Response Metadata
| Field | Type | Description |
|---|---|---|
message | string | Success message |
cartTotal | decimal | Updated cart total |
Validation
- Quantity must be at least 1
- Quantity cannot exceed available stock
- Attributes must be valid for the product
Use Cases
- Change quantity in cart view
- Update product variations (size, color)
- Modify options before checkout
- Adjust selections on cart page

