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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | ID of the cart item to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| quantity | Integer | No | Quantity to add (default: 1, minimum: 1) |
| notes | String | No | Customer notes for this item (max 500 chars) |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# Update item quantity and notes
2curl -X PATCH "http://www.example.com/api/shop/cart/items/789" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
3 "quantity": 5,
4 "notes": "Updated notes"
5}'
6
7# Update only quantity
8curl -X PATCH "http://www.example.com/api/shop/cart/items/789" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
9 "quantity": 3
10}'Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the cart item |
| ref | String | Item reference (read-only) |
| product | Object | Product information with `id`, `name`, `image` |
| quantity | Integer | Item quantity |
| notes | String | Customer notes for this item |
| created_at | String (ISO 8601) | Timestamp when item was added |
| updated_at | String (ISO 8601) | Timestamp when item was last updated |
| unit_price | Integer | Price per unit (read-only) |
| unit_discount | Integer | Discount per unit (read-only) |
| subtotal | Integer | Item subtotal before discount (read-only) |
| discount | Integer | Total item discount (read-only) |
| total | Integer | Final item total (read-only) |
Product Object Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique id of the product |
| title | String | Product title |
| image | Object | Product image details |
Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
Example Response
{
"id": 1,
"address": 1,
"shipping_method": 1,
"payment_method": 1,
"created_at": "2025-11-22T15:26:59.108182Z",
"updated_at": "2025-12-30T12:53:24.505447Z",
"count": 1,
"quantity": 8,
"is_empty": false,
"items_subtotal": 8000,
"items_discount": 800,
"subtotal": 8000,
"discount": 800,
"shipping_cost": 0,
"total": 7200,
"items": [
{
"id": 4,
"ref": "54",
"product": {
"id": 54,
"title": "درب سمت راست پراید",
"image": null
},
"quantity": 8,
"notes": "fuga sed aperiam",
"created_at": "2025-12-30T13:17:46.941326Z",
"updated_at": "2025-12-30T13:36:46.482396Z",
"unit_price": 1000,
"unit_discount": 100,
"subtotal": 8000,
"discount": 800,
"total": 7200
}
]
}