Skip to main content

Update Order Item

Update an existing order item.

HTTP Request

PATCH/api/orders/:id/items/:item_id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the order to update
item_idIntegerYesUnique ID of the order item to update

Request Body

FieldTypeRequiredDescription
productIntegerYesProduct ID
unit_priceNumberYesPrice per unit
unit_discountNumberNoDiscount per unit
quantityIntegerNoQuantity of items (default: 1)
notesStringNoItem-specific notes

Example Requests

1import requests
2
3response = requests.patch('http://www.example.com/api/orders/123/items/789', 
4  json={
5      'quantity': 3,
6      'unit_discount': 5.00
7  },
8  headers={'Authorization': 'Token <your_api_key>'}
9)
10print(response.json())

Status Codes

CodeDescription
200Order Item updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — order item does not exist
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the order
keyStringUnique key of the order (read-only)
statusStringCurrent status of the order
customer_dataObjectCustomer information (read-only)
payment_method_dataObjectPayment method information (read-only)
shipping_method_dataObjectShipping method information (read-only)
shipping_costNumberCost of shipping
notesStringOrder notes
extraObjectAdditional order data
created_atString (ISO 8601)Timestamp when order was created
updated_atString (ISO 8601)Timestamp when order was last updated
billing_country_dataObjectBilling country information (read-only)
billing_state_dataObjectBilling state information (read-only)
billing_city_dataObjectBilling city information (read-only)
billing_addressStringBilling address
billing_postal_codeStringBilling postal code
billing_national_codeStringBilling national code
billing_mobile_numberStringBilling mobile number
billing_first_nameStringBilling first name
billing_last_nameStringBilling last name
countIntegerNumber of items in order (computed field)
quantityIntegerTotal quantity of items (computed field)
items_subtotalNumberSubtotal of all items (computed field)
items_discountNumberTotal discount on items (computed field)
subtotalNumberOrder subtotal (computed field)
total_discountNumberTotal discount amount (computed field)
totalNumberOrder total amount (computed field)
amount_paidNumberAmount already paid (computed field)
amount_outstandingNumberOutstanding amount (computed field)
is_paidBooleanWhether order is fully paid (computed field)
itemsArrayList of order items (read-only)
paymentsArrayList of order payments (read-only)

Order Items Structure

Each item in the items array contains:

FieldTypeDescription
idIntegerUnique ID of the order item
productIntegerUnique ID of the product
product_nameStringCurrent Product Name
product_dataObjectSnapshot of product data at time of order
unit_priceIntegerPrice per unit (in smallest currency unit)
unit_discountIntegerDiscount per unit (in smallest currency unit)
quantityIntegerQuantity ordered
notesStringItem-specific notes
subtotalIntegerCalculated subtotal (computed field)
discountIntegerTotal discount for this item (computed field)
totalIntegerFinal total for this item (computed field)
created_atString (ISO 8601)Item creation timestamp
updated_atString (ISO 8601)Item last update timestamp

Payment Method Structure

The payment_method object contains:

FieldTypeDescription
idIntegerPayment method ID
nameStringPayment method name
imageObjectPayment method image data

Customer Structure

The customer object contains:

FieldTypeDescription
idIntegerCustomer ID
usernameStringCustomer username
full_nameStringCustomer full name (computed)

Geographic Data Structures

Country, state, and city objects contain:

Country/State:

FieldTypeDescription
idIntegerLocation ID
activeBooleanWhether location is active
nameStringLocation name
codeStringLocation code

City:

FieldTypeDescription
idIntegerCity ID
activeBooleanWhether city is active
nameStringCity name