Updates an item (product) in an order, such as its code, name, quantity, price or attributes. All fields except Order_ID and Line_ID are optional. The response has the new order total.
Before you begin#
- The API token needs
OrderItem_Update, either assigned directly under Functions or through a group. See Create an API token. - Requests must be signed if the token requires it. See Make a signed request with HMAC.
- You need the order ID and the item’s
line_id.OrderList_Load_Queryreturns both.
Example requests#
Update an item#
Changes line 154 of order 200101 to 3 small red shirts at a new price, with size and color attributes.
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "OrderItem_Update",
"line_id": 154,
"Order_ID": 200101,
"Code": "shirt",
"Name": "Custom T-Shrt",
"SKU": "shirt-red-small",
"Quantity": 3,
"Price": 10.58,
"Weight": 1,
"Taxable": true,
"Attributes": [
{
"attr_code": "size",
"opt_code_or_data": "small",
"price": 0,
"weight": 0
},
{
"attr_code": "color",
"opt_code_or_data": "red",
"price": 0,
"weight": 0
}
]
}
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id |
Number | Order Id to add item to | |
line_id |
Number | Yes | The line_id is the id of the line item in the order. This value is returned in OrderList_Load_Query |
code |
String | No | Product Code to Add (this does not need to exist as a product in Miva’s Database) |
name |
String | No | Product Name |
sku |
String | No | Product SKU |
quantity |
Number | No | Product Quantity |
Price |
Price | No | Optional. Item price |
weight |
Number | No | Weight |
Taxable |
Boolean | No | Taxable |
attributes |
Object | Attributes |
attributes object#
| Parameter | Type | Description |
|---|---|---|
attr_code |
Number | Attribute Code |
opt_code_or_data |
String | Option Code/Data. Note. You can use this parameter or opt_code. Both are not required |
opt_code |
String | Option Code |
price |
Number | Price |
weight |
Number | Weight |
Example response#
{
"success": 1,
"data": {
"total": 63.48,
"formatted_total": "$63.48"
}
}
Response parameters#
| Parameter | Type | Description |
|---|---|---|
total |
Number | Order Total after new item has been added. |
formatted_total |
String | Currency Formatted Order Total |
Error responses#
| Error Code | Error Message | Error Description |
|---|---|---|
| MER-JSN-ORD-00025 | Order not found | Order number not found |
| MER-JSN-00023 | One or more parameters are invalid | Missing required line_id parameter |
| EOF | Record not found: MER-DBP-OIT-00007 | line_id passed is not valid |
Related functions#
| Function | Use it to |
|---|---|
OrderList_Load_Query |
Find the order and its line IDs |
OrderItem_Add |
Add an item to an order |
OrderItem_Split |
Split an item into two lines |
OrderItemList_Delete |
Delete items from an order |
OrderItemList_Cancel |
Cancel items in an order |
Try in Postman#
In the Miva: JSON API: Authenticated collection, open Orders > OrderItem_Update. See Set Up Postman.