Create Order Item
Create a new order item.
HTTP Request
POST/api/orders/:order_id/items
Authorization
Authorization
- Required: Yes
- Permission: Staff with OrderItemPermission or Admin
- Permission Code: 2221
- Authentication: Token-based (Authorization: Token <your_api_key>)
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| product | Integer | Yes | Product ID |
| unit_price | Number | Yes | Price per unit |
| unit_discount | Number | No | Discount per unit |
| quantity | Integer | No | Quantity of items (default: 1) |
| notes | String | No | Item-specific notes |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3response = requests.post('http://www.example.com/api/orders/123/items',
4 json={
5 'product': 456,
6 'unit_price': 35000,
7 'quantity': 2,
8 'notes': 'Gift wrap requested'
9 },
10 headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())1curl -X POST "http://www.example.com/api/orders/123/items" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
2 "product": 456,
3 "unit_price": 35000,
4 "quantity": 2,
5 "notes": "Gift wrap requested"
6}'Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order |
| key | String | Unique key of the order (read-only) |
| status | String | Current status of the order |
| customer_data | Object | Customer information (read-only) |
| payment_method_data | Object | Payment method information (read-only) |
| shipping_method_data | Object | Shipping method information (read-only) |
| shipping_cost | Number | Cost of shipping |
| notes | String | Order notes |
| extra | Object | Additional order data |
| created_at | String (ISO 8601) | Timestamp when order was created |
| updated_at | String (ISO 8601) | Timestamp when order was last updated |
| billing_country_data | Object | Billing country information (read-only) |
| billing_state_data | Object | Billing state information (read-only) |
| billing_city_data | Object | Billing city information (read-only) |
| billing_address | String | Billing address |
| billing_postal_code | String | Billing postal code |
| billing_national_code | String | Billing national code |
| billing_mobile_number | String | Billing mobile number |
| billing_first_name | String | Billing first name |
| billing_last_name | String | Billing last name |
| count | Integer | Number of items in order (computed field) |
| quantity | Integer | Total quantity of items (computed field) |
| items_subtotal | Number | Subtotal of all items (computed field) |
| items_discount | Number | Total discount on items (computed field) |
| subtotal | Number | Order subtotal (computed field) |
| total_discount | Number | Total discount amount (computed field) |
| total | Number | Order total amount (computed field) |
| amount_paid | Number | Amount already paid (computed field) |
| amount_outstanding | Number | Outstanding amount (computed field) |
| is_paid | Boolean | Whether order is fully paid (computed field) |
| items | Array | List of order items (read-only) |
| payments | Array | List of order payments (read-only) |
Customer Structure
The customer object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Customer ID |
| username | String | Customer username |
| mobile_number | String | Customer mobile number |
| first_name | String | Customer first name |
| last_name | String | Customer last name |
| full_name | String | Customer full name (computed) |
Payment Method Structure
The payment_method object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Payment method ID |
| name | String | Payment method name |
| image | Object | Payment method image data |
Shipping Method Structure
The shipping_method object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Shipping method ID |
| name | String | Shipping method name |
| image | Object | Shipping method image data |
Geographic Data Structures
Country, state, and city objects contain:
Country/State:
| Field | Type | Description |
|---|---|---|
| id | Integer | Location ID |
| name | String | Location name |
| code | String | Location code |
City:
| Field | Type | Description |
|---|---|---|
| id | Integer | City ID |
| name | String | City name |
Order Items Structure
Each item in the items array contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order item |
| product | Integer | Unique ID of the product |
| product_name | String | Current Product Name |
| product_data | JsonField | Snapshot of product data at time of order |
| unit_price | Integer | Price per unit (in smallest currency unit) |
| unit_discount | Integer | Discount per unit (in smallest currency unit) |
| quantity | Integer | Quantity ordered |
| notes | String | Item-specific notes |
| subtotal | Integer | Calculated subtotal (computed field) |
| discount | Integer | Total discount for this item (computed field) |
| total | Integer | Final total for this item (computed field) |
| created_at | String (ISO 8601) | Item creation timestamp |
| updated_at | String (ISO 8601) | Item last update timestamp |
Order Payment Structure
Each item in the payments array contains:
- The shipping method structure here is the same as the above-mentioned ShippingMethod Structure.
| Field | Type | Description |
|---|---|---|
| id | Integer | Id of the order payment |
| payment_method_data | Object | Payment method data of the order payment |
| approved | Boolean | Whether the order payment is approved |
| amount | Integer | The order payment amount |
| transaction_id | String | The transaction id of the order payment |
| notes | String | The extra notes about the order payment |
| created_at | String (ISO 8601) | The creation datetime of the order payment |
| updated_at | String (ISO 8601) | The last updated datetime of the order payment |
Example Response
{
"id": 2,
"key": "0c86ab758d3e236cb5a4",
"status": "shipped",
"customer_data": {
"id": 1,
"username": "BehroozGhorbani",
"mobile_number": "09308744204",
"first_name": "بهروز",
"last_name": "قربانی",
"full_name": "بهروز قربانی"
},
"payment_method_data": {
"id": 1,
"name": "پرداخت در مخل",
"image": null
},
"shipping_method_data": {
"id": 1,
"name": "پیک موتور",
"image": {
"id": 8,
"type": "image",
"name": "پیک موتوری",
"size": 808754,
"human_readable_size": "789.80 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/12/20/Fantasticheskie_kartinki_dlja_monitora_68_63.jpg",
"width": 1920,
"height": 1080,
"mode": "RGB"
}
},
"shipping_cost": 75000,
"notes": "Facilis sequi alias optio. Alias ipsam deserunt. At veniam nam et. Et aut id id aut quae non animi. Sed tempora aut ut ipsa dicta vel eveniet et aspernatur.",
"extra": {
"some": "data"
},
"created_at": "2025-12-27T18:17:09.771123Z",
"updated_at": "2025-12-28T11:28:47.290350Z",
"billing_country_data": {
"id": 1,
"name": "ایران",
"code": "IR"
},
"billing_state_data": {
"id": 1,
"name": "آذربایجان شرقی",
"code": "EA"
},
"billing_city_data": {
"id": 1,
"name": "اسکو"
},
"billing_address": "5411 Stokes Grove",
"billing_postal_code": "1234567890",
"billing_national_code": null,
"billing_mobile_number": "09523296536",
"billing_first_name": "پدرام",
"billing_last_name": "زمانی",
"count": 1,
"quantity": 5,
"items_subtotal": 48900000,
"items_discount": 400000,
"subtotal": 48900000,
"total_discount": 400000,
"total": 48575000,
"amount_paid": 500000,
"amount_outstanding": 48075000,
"is_paid": false,
"is_payable": true,
"items": [
{
"id": 8,
"product": 36,
"product_title": "ماوس لاجیتک MX Vertical",
"product_data": {
"id": 36,
"code": "1001001",
"slug": "logitech-mouse-mx-vertical",
"image": {
"f": "http://127.0.0.1:8000/media/core_media/2025/11/22/logitech-mx-1.jpg",
"id": 2,
"mode": "RGB",
"name": "logitech-mx-1",
"size": 4766,
"type": "image",
"width": 225,
"height": 225,
"human_readable_size": "4.65 KB"
},
"title": "ماوس لاجیتک MX Vertical"
},
"unit_price": 9780000,
"unit_discount": 80000,
"quantity": 5,
"notes": "some random note",
"subtotal": 48900000,
"discount": 400000,
"total": 48500000,
"created_at": "2025-12-28T11:29:10.190784Z",
"updated_at": "2025-12-28T11:29:10.190792Z"
}
],
"payments": [
{
"id": 1,
"payment_method_data": {
"id": 1,
"name": "پرداخت در مخل",
"image": null
},
"approved": true,
"amount": 500000,
"transaction_id": "1589800",
"notes": "",
"created_at": "2025-12-28T10:43:38.509103Z",
"updated_at": "2025-12-28T10:43:38.509107Z"
}
]
}