Created by potrace 1.16, written by Peter Selinger 2001-2019

Miva Developer Docs

Adds an item (product) to an order.


Adds an item (product) to an existing order. The product code doesn’t need to exist in the catalog. The response has the new order total and the new order item, including its line_id.

Before you begin#

  • The API token needs OrderItem_Add, 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 ID of the order to add the item to.

Example requests#

Add an item#

Adds 3 small red shirts to order 1000, with size and color attributes.

{
    "Store_Code": "{{Store_Code}}",
    "Miva_Request_Timestamp": "{{$timestamp}}",
    "Function": "OrderItem_Add",
    "Order_ID": 1000,
    "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
code String Yes Product Code to Add (this does not need to exist as a product in Miva’s Database)
name String Yes Product Name
sku String No Product SKU
quantity Number Yes 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
opt_code String Option Code
price Number Price
weight Number Weight

Example response#

The response to the example, shortened to one option.

{
    "success": 1,
    "data": {
        "total": 31.74,
        "formatted_total": "$31.74",
        "orderitem": {
            "order_id": 1000,
            "line_id": 161,
            "status": 0,
            "subscrp_id": 0,
            "subterm_id": 0,
            "rma_id": 0,
            "dt_instock": 0,
            "code": "shirt",
            "name": "Custom T-Shrt",
            "sku": "shirt-red-small",
            "retail": 0.0,
            "base_price": 10.58,
            "price": 10.58,
            "weight": 1.0,
            "taxable": true,
            "upsold": false,
            "quantity": 3,
            "options": [
                {
                    "id": 85,
                    "order_id": 1000,
                    "line_id": 161,
                    "attr_id": 0,
                    "attr_code": "color",
                    "attmpat_id": 0,
                    "option_id": 0,
                    "opt_code": "",
                    "retail": 0.0,
                    "base_price": 0.0,
                    "price": 0.0,
                    "weight": 0.0,
                    "data": "red",
                    "data_long": "",
                    "attr_prompt": "",
                    "opt_prompt": "",
                    "attribute": "color",
                    "value": "red"
                }
            ],
            "total": 31.74
        }
    }
}
Full response
{
    "success": 1,
    "data": {
        "total": 31.74,
        "formatted_total": "$31.74",
        "orderitem": {
            "order_id": 1000,
            "line_id": 161,
            "status": 0,
            "subscrp_id": 0,
            "subterm_id": 0,
            "rma_id": 0,
            "dt_instock": 0,
            "code": "shirt",
            "name": "Custom T-Shrt",
            "sku": "shirt-red-small",
            "retail": 0.0,
            "base_price": 10.58,
            "price": 10.58,
            "weight": 1.0,
            "taxable": true,
            "upsold": false,
            "quantity": 3,
            "options": [
                {
                    "id": 85,
                    "order_id": 1000,
                    "line_id": 161,
                    "attr_id": 0,
                    "attr_code": "color",
                    "attmpat_id": 0,
                    "option_id": 0,
                    "opt_code": "",
                    "retail": 0.0,
                    "base_price": 0.0,
                    "price": 0.0,
                    "weight": 0.0,
                    "data": "red",
                    "data_long": "",
                    "attr_prompt": "",
                    "opt_prompt": "",
                    "attribute": "color",
                    "value": "red"
                },
                {
                    "id": 84,
                    "order_id": 1000,
                    "line_id": 161,
                    "attr_id": 0,
                    "attr_code": "size",
                    "attmpat_id": 0,
                    "option_id": 0,
                    "opt_code": "",
                    "retail": 0.0,
                    "base_price": 0.0,
                    "price": 0.0,
                    "weight": 0.0,
                    "data": "small",
                    "data_long": "",
                    "attr_prompt": "",
                    "opt_prompt": "",
                    "attribute": "size",
                    "value": "small"
                }
            ],
            "total": 31.74
        }
    }
}

Response parameters#

Parameter Type Description
total Number Order Total after new item has been added
formatted_total String Currency Formatted Order Total
orderitem Object Record for newly created order item

orderitem object#

Parameter Type Description
order_id Number Order ID
line_id Number Line ID
status Number Item Status
subscrp_id Number Subscription ID
subterm_id Number Subscription Term Id
rma_id Number Return Merchandise Authorization Id
dt_instock Number Date/Time Instock (Unix timestamp)
code String Code
name String Name
sku String Sku Number
retail Number Retail Price
base_price Number Base Price
price Number Price
weight Number Weight
taxable Boolean Taxable
upsold Boolean Upsold
quantity Number Quantity
options Array Options

Error responses#

Error Code Error Message Error Description
MER-JSN-ORD-00025 Order not found Order number not found.
Function Use it to
OrderItem_Update Change an item in an order
OrderItemList_Delete Delete items from an order
OrderItem_Split Split an item into two lines
Order_Create Create an order with its items
OrderList_Load_Query Load the order and its items

Try in Postman#

In the Miva: JSON API: Authenticated collection, open Orders > OrderItem_Add. See Set Up Postman.