Skip to content

Order_Create#


Description#

This function allows you to create a new order. This function takes input parameters for both items and products. Items allows you to add any item to an order. It does not need to match any existing product in the catalog. When using the products object, Miva will validate that product code exists and load data from that product such as price, weight, name, and cost.

Request Body Parameters#

Parameter
Type 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 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
ShipFirstName String FirstName for Bill To address
ShipLastName String LastName for Bill To address
ShipEmail String Email for Bill To address
ShipPhone String Phone Number for Bill To address
ShipFax String Fax Number for Bill To address
ShipCompany String Company Name for Bill To address
ShipAddress1 String Address line 1 for Bill To address
ShipAddress2 String Address line 2 for Bill To address
ShipCity String City for Bill To address
ShipState String State for Bill To Address
ShipZip String Zip Code for Bill To address
ShipCountry String Country for Bill To Address
OrderDate Number 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
CustomFields Object Object containing the custom fields for the order
Shipping_Module_Code String Shipping Module Code
Shipping_module_Data String Typically Shipping Method Name
CalculateCharges Boolean Boolean Value to have Miva re-calculate tax and shipping values based on Shipping Module/Method sent.
TriggerFulfillmentModules Boolean 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 not 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

CustomFields Object#

Parameter
Type Description
module_code String Module Code, ex: customfields
field_code String Custom Field Code
value String Custom Field Value

Example Request#

{
    "Store_Code": "{{Store_Code}}",
    "Miva_Request_Timestamp": "{{$timestamp}}",
    "Function": "Order_Create",
    "Customer_Login": "jdoe",
    "ShipFirstName": "John",
    "ShipLastName": "Smith",
    "ShipEmail": "test@miva.com",
    "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": "ssoule@miva.com",
    "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": [{
            "module_code": "customfields",
            "field_code": "order_instructions",
            "value": "This is a test"
        }]
    },
    "Shipping_Module_Code": "flatrate",
    "Shipping_Module_Data": "Free Shipping",
    "CalculateCharges": false,
    "Calculate_Tax": false,
    "TriggerFulfillmentModules": false
}

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": "john@example.com",
        "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": [
        ]
    }
}