Creates a new order from items, catalog products, charges and custom field values.
Creates a new order. It takes both items and products. Items lets you add any item to an order, and it doesn’t need to match an existing product in the catalog. With Products, Miva checks that the product code exists and loads data from that product such as price, weight, name and cost. For pulling orders out of Miva instead, see the Order integration guide.
Before you begin#
- The API token needs
Order_Create, 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.
- Products passed in
Productsmust already exist in the catalog. Items passed inItemsdon’t.
Example requests#
Create an order#
Creates an order for customer jdoe with one custom item, one catalog product, a coupon and tax charge, and custom field values.
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "Order_Create",
"Customer_Login": "jdoe",
"ShipFirstName": "John",
"ShipLastName": "Smith",
"ShipEmail": "[email protected]",
"ShipPhone": "8585551234",
"ShipFax": "8585554321",
"ShipCompany": "Miva, Inc.",
"ShipAddress1": "16745 West Bernardo Road",
"ShipAddress2": "Suite 400",
"ShipCity": "San Diego",
"ShipState": "CA",
"ShipZip": "92127",
"ShipCountry": "US",
"ShipResidential": false,
"BillFirstName": "John",
"BillLastName": "Smith",
"BillEmail": "[email protected]",
"BillPhone": "8585555678",
"BillFax": "8585558765",
"BillCompany": "Miva2, Inc.",
"BillAddress1": "26745 West Bernardo Road",
"BillAddress2": "Suite 410",
"BillCity": "Stan Diego",
"BillState": "CA",
"BillZip": "92027",
"BillCountry": "US",
"Items": [
{
"status": 0,
"code": "aaaaa",
"name": "Item 3",
"sku": "SKUITEM3",
"price": 1.97,
"weight": 0.08,
"quantity": 2,
"taxable": true,
"upsold": false,
"options": [
{
"attr_code": "color",
"opt_code": "green",
"price": 0.28,
"weight": 0.01
}
]
}
],
"Products": [
{
"status": 0,
"code": "shirt",
"quantity": 2,
"attributes": [
{
"code": "color",
"template_code": "",
"value": "red"
},
{
"code": "size",
"template_code": "",
"value": "small"
}
]
}
],
"Charges": [
{
"type": "COUPON",
"descrip": "Coupon: 20% Off",
"amount": -0.25,
"display_amount": -0.26,
"tax_exempt": true
},
{
"type": "TAX",
"descrip": "Sales Tax",
"amount": 1.25,
"display_amount": 1.25,
"tax_exempt": true
}
],
"CustomField_Values": {
"customfields": {
"checkbox_CUSTOMFIELD_CODE": true,
"text_CUSTOMFIELD_CODE": "fffff",
"textarea_CUSTOMFIELD_CODE": "ggggg",
"dropdown_CUSTOMFIELD_CODE": "bbbbb",
"multitext_CUSTOMFIELD_CODE": [
"hhhhh",
"iiiii"
]
}
},
"Shipping_Module_Code": "flatrate",
"Shipping_Module_Data": "Free Shipping",
"CalculateCharges": false,
"TriggerFulfillmentModules": false
}
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
Customer_Login |
String | Customer to assign the order to | |
Customer_ID |
Number | Customer to assign the order to (only customer_login or customer_id can be sent) | |
Order_Id |
Number | No | If omitted, Miva will automatically assign an order id to the order. |
ShipFirstName |
String | FirstName for Ship To address | |
ShipLastName |
String | LastName for Ship To address | |
ShipEmail |
String | Email for Ship To address | |
ShipPhone |
String | Phone Number for Ship To address | |
ShipFax |
String | Fax Number for Ship To address | |
ShipCompany |
String | Company Name for Ship To address | |
ShipAddress1 |
String | Address line 1 for Ship To address | |
ShipAddress2 |
String | Address line 2 for Ship To address | |
ShipCity |
String | City for Ship To address | |
ShipState |
String | State for Ship To Address | |
ShipZip |
String | Zip Code for Ship To address | |
ShipCountry |
String | Country for Ship To Address | |
ShipResidential |
Boolean | Whether the Ship To address is residential | |
BillFirstName |
String | FirstName for Bill To address | |
BillLastName |
String | LastName for Bill To address | |
BillEmail |
String | Email for Bill To address | |
BillPhone |
String | Phone Number for Bill To address | |
BillFax |
String | Fax Number for Bill To address | |
BillCompany |
String | Company Name for Bill To address | |
BillAddress1 |
String | Address line 1 for Bill To address | |
BillAddress2 |
String | Address line 2 for Bill To address | |
BillCity |
String | City for Bill To address | |
BillState |
String | State for Bill To Address | |
BillZip |
String | Zip Code for Bill To address | |
BillCountry |
String | Country for Bill To Address | |
OrderDate |
Number | No | UNIX Timestamp of Order Date |
Items |
Object | Object containing all the items in the order | |
Products |
Object | Object containing all the product groups in the order | |
Charges |
Object | Object containing the charges for the order | |
CustomField_Values |
Object | Object containing the custom fields for the order | |
Shipping_Module_Code |
String | Yes | Shipping Module Code |
Shipping_Module_Data |
String | Yes | Typically Shipping Method Name |
CalculateCharges |
Boolean | No | Boolean Value to have Miva re-calculate tax and shipping values based on Shipping Module/Method sent. |
TriggerFulfillmentModules |
Boolean | No | Boolean Value to have Miva trigger fulfillment modules (Send Order Confirmation Emails) |
Items Object#
Using the Items object the product data (ie Name, price, weight) must be sent in the request.
| Parameter | Type | Description |
|---|---|---|
status |
Number | Item Status. 0 = Pending 100 = Picking 200 = Shipped 210 = Gift Certificate: Not Redeemed 211 = Gift Certificate: Redeemed 220 = Digital: Not Downloaded 221 = Digital: Downloaded 300 = Cancelled 400 = Backordered 500 = RMA Issued 600 = Returned |
Code |
String | Item Code |
Name |
String | Item Name |
SKU |
String | SKU |
tracknum |
String | Optional Tracking Number if item is already shipped |
tracktype |
String | Tracking Type. Default Types include “CanadaPost”, “Endicia”, “FedEx”, “UPS”, “USPS”. |
price |
Number | Price |
weight |
Number | Weight |
quantity |
Number | Quantity |
taxable |
Boolean | Taxable |
upsold |
Boolean | Upsold |
Options |
Object | Object containing the items options |
Items.Options Object#
| Parameter | Type | Description |
|---|---|---|
opt_code_or_data |
String | You can pass this value OR opt_code below. |
attr_code |
String | attr_code |
opt_code |
String | Option Code |
Price |
Number | Option Price |
Weight |
Number | Option Weight |
Products Object#
Using the Products object Miva will use the default product data if not set in the request.
| Parameter | Type | Description |
|---|---|---|
status |
Number | Item Status. 0 = Pending, 100 = Picking, 200 = Shipped, 210 = Gift Certificate: Not Redeemed, 211 = Gift Certificate: Redeemed, 220 = Digital: Not Downloaded, 221 = Digital: Downloaded , 300 = Cancelled, 400 = Backordered, 500 = RMA Issued, 600 = Returned |
Code |
String | Code |
SKU |
String | SKU |
tracknum |
String | tracknum |
tracktype |
String | tracktype |
quantity |
Number | quantity |
Attributes |
Object | Attributes |
Products.Attributes Object#
| Parameter | Type | Description |
|---|---|---|
code |
String | code |
template_code |
String | Attribute Template Code. Empty if an attribute template is not being used. |
Value |
String | Attribute Value |
Charges Object#
| Parameter | Type | Description |
|---|---|---|
type |
String | Default Types include: TAX, SHIPPING, DISCOUNT, COUPON |
descrip |
String | Charge Description |
amount |
Number | Amount |
display_amount |
Number | Display Amount |
tax_exempt |
Boolean | Tax Exempt |
CustomField_Values Object#
| Parameter | Type | Description |
|---|---|---|
customfields |
Object | Module Code, ex: customfields |
customfields Object#
| Parameter | Type | Description |
|---|---|---|
field_code (This is the custom field code) |
String/Number/Boolean/Object | Value that will be the added to the custom field |
Example response#
{
"success": 1,
"data": {
"id": 1028,
"pay_id": 0,
"batch_id": 0,
"status": 0,
"pay_status": 0,
"stk_status": 0,
"dt_instock": 0,
"orderdate": 1020458473,
"cust_id": 0,
"ship_res": true,
"ship_fname": "John",
"ship_lname": "Doe",
"ship_email": "[email protected]",
"ship_comp": "",
"ship_phone": "123-456-7890",
"ship_fax": "",
"ship_addr1": "123 Main St",
"ship_addr2": "",
"ship_city": "Springfield",
"ship_state": "IL",
"ship_zip": "62701",
"ship_cntry": "US",
"bill_fname": "",
"bill_lname": "",
"bill_email": "",
"bill_comp": "",
"bill_phone": "",
"bill_fax": "",
"bill_addr1": "",
"bill_addr2": "",
"bill_city": "",
"bill_state": "",
"bill_zip": "",
"bill_cntry": "",
"ship_id": 0,
"ship_data": "",
"ship_method": "None",
"source": "user",
"source_id": 0,
"total": 0.00,
"formatted_total": "$0.00",
"total_ship": 0.00,
"formatted_total_ship": "$0.00",
"total_tax": 0.00,
"formatted_total_tax": "$0.00",
"total_auth": 0.00,
"formatted_total_auth": "$0.00",
"total_capt": 0.00,
"formatted_total_capt": "$0.00",
"total_rfnd": 0.00,
"formatted_total_rfnd": "$0.00",
"net_capt": 0.00,
"formatted_net_capt": "$0.00",
"pend_count": 0,
"bord_count": 0,
"note_count": 0,
"dt_updated": 1720458613,
"items": [
],
"charges": [
]
}
}
Response parameters#
The response’s data is the new order. Its fields are the order fields described in OrderList_Load_Query response parameters.
Related functions#
| Function | Use it to |
|---|---|
Order_Create_FromOrder |
Create an order by copying another order’s customer and addresses |
OrderItem_Add |
Add an item to an existing order |
OrderList_Load_Query |
Load the order after it’s created |
Order_Authorize |
Authorize payment for the order |
OrderCoupon_Update_Assigned |
Assign a coupon to the order |
Order_Delete |
Delete an order |
Try in Postman#
In the Miva: JSON API: Authenticated collection, open Orders > Order_Create. See Set Up Postman.