Skip to main content

Update Item in Cart

Updates the quantity or notes of an existing item in the cart.

HTTP Request

PATCH/api/shop/cart/items/:id

Authorization

Authorization

  • Required: Yes
  • Permission: Authenticated User
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesID of the cart item to update

Request Body

FieldTypeRequiredDescription
quantityIntegerNoQuantity to add (default: 1, minimum: 1)
notesStringNoCustomer notes for this item (max 500 chars)

Example Requests

1import requests
2
3# Update item quantity and notes
4response = requests.patch('http://www.example.com/api/shop/cart/items/789', 
5  json={
6      'quantity': 5,
7      'notes': 'Updated notes'
8  },
9  headers={'Authorization': 'Token <your_api_key>'}
10)
11print(response.json())
12
13# Update only quantity
14response = requests.patch('http://www.example.com/api/shop/cart/items/789', 
15  json={
16      'quantity': 3
17  },
18  headers={'Authorization': 'Token <your_api_key>'}
19)
20print(response.json())

Status Codes

CodeDescription
200Item updated in cart successfully
400Bad request — invalid product, insufficient stock, or validation error
401Unauthorized — authentication required
404Item not found
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the product
addressIntegerSelected delivery address ID
shipping_methodIntegerSelected shipping method ID
payment_methodIntegerSelected payment method ID
created_atString (ISO 8601)Timestamp when cart was created
updated_atString (ISO 8601)Timestamp when cart was last updated
countIntegerNumber of unique items in cart
quantityIntegerTotal quantity of all items
is_emptyBooleanWhether the cart is empty
items_subtotalIntegerSubtotal of all items before discounts
items_discountIntegerTotal discount amount on items
subtotalIntegerCart subtotal after item discounts
discountIntegerAdditional cart-level discount
totalIntegerFinal cart total
itemsArrayArray of cart items (see Cart Item fields)

Cart Item Fields

FieldTypeDescription
idIntegerUnique ID of the cart item
refStringItem reference (read-only)
productObjectProduct information with `id`, `name`, `image`
quantityIntegerItem quantity
notesStringCustomer notes for this item
created_atString (ISO 8601)Timestamp when item was added
updated_atString (ISO 8601)Timestamp when item was last updated
unit_priceIntegerPrice per unit (read-only)
unit_discountIntegerDiscount per unit (read-only)
subtotalIntegerItem subtotal before discount (read-only)
discountIntegerTotal item discount (read-only)
totalIntegerFinal item total (read-only)