Creates a new order, using a previous order as a reference, and returns the new order. It behaves the same as clicking the “New Order” button on the order detail screen in the admin. It copies the customer assignment, bill to, ship to and saved card (if using MivaPay). Item, shipping, tax and discount data aren’t copied.
Before you begin#
- The API token needs
Order_Create_FromOrder, 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.
- Available in Version 9.13 or greater.
- You need the ID of the order to copy from.
Example requests#
Copy an order#
Creates a new order from order 1017.
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "Order_Create_FromOrder",
"Order_ID": 1017
}
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
Order_Id |
Number | This is the reference Order Id to copy data from when creating the new order. |
Example response#
{
"success": 1,
"data": {
"id": 1034,
"pay_id": 0,
"batch_id": 0,
"status": 0,
"pay_status": 0,
"stk_status": 0,
"dt_instock": 0,
"orderdate": 1551813654,
"cust_id": 0,
"ship_res": false,
"ship_fname": "John",
"ship_lname": "Doe",
"ship_email": "[email protected]",
"ship_comp": "MIva, Inc",
"ship_phone": "8587314220",
"ship_fax": "",
"ship_addr1": "16745 W. Bernardo Dr, Fourth Floor",
"ship_addr2": "",
"ship_city": "San Diego",
"ship_state": "CA",
"ship_zip": "92127",
"ship_cntry": "US",
"bill_fname": "John",
"bill_lname": "Doe",
"bill_email": "[email protected]",
"bill_comp": "MIva, Inc",
"bill_phone": "8587314220",
"bill_fax": "",
"bill_addr1": "16745 W. Bernardo Dr, Fourth Floor",
"bill_addr2": "",
"bill_city": "San Diego",
"bill_state": "CA",
"bill_zip": "92127",
"bill_cntry": "US",
"ship_id": 0,
"ship_data": "",
"ship_method": "None",
"source": "",
"source_id": 0,
"total": 0.0,
"formatted_total": "$0.00",
"total_ship": 0.0,
"formatted_total_ship": "$0.00",
"total_tax": 0.0,
"formatted_total_tax": "$0.00",
"total_auth": 0.0,
"formatted_total_auth": "$0.00",
"total_capt": 0.0,
"formatted_total_capt": "$0.00",
"total_rfnd": 0.0,
"formatted_total_rfnd": "$0.00",
"net_capt": 0.0,
"formatted_net_capt": "$0.00",
"pend_count": 0,
"bord_count": 0,
"note_count": 0
}
}
Response parameters#
| Parameter | Type | Description |
|---|---|---|
id |
Number | Order Number for the Order |
pay_id |
Number | Id of Payment Module Used in transaction |
batch_id |
Number | Batch ID |
status |
Number | Order Status. 0 = Pending, 100 = Processing, 200 = Shipped, 201 = Partially Shipped, 300 = Cancelled, 400 = Backordered, 500 = RMA Issued, 600 = Returned |
pay_status |
Number | Payment Status. 0 = Pending, 100 = Authorized, 200 = Captured, 201 = Partially Captured |
stk_status |
Number | Stock Status. 0 = Pending, 100 = yes, 200 = no, 201 = partial |
dt_instock |
Unix Timestamp | Date/Time Instock (Unix timestamp). 0 if Not set |
orderdate |
Unix Timestamp | Order Date |
cust_id |
Number | Customer ID |
ship_res |
Boolean | Ship Residential Flag |
ship_fname |
String | Shipping First Name |
ship_lname |
String | Shipping Last Name |
ship_email |
String | Shipping Email Address |
ship_comp |
String | Shipping Company |
ship_phone |
String | Shipping Phone Number |
ship_fax |
String | Shipping Fax Number |
ship_addr1 |
String | Shipping Address Line 1 |
ship_addr2 |
String | Shipping Address Line 2 |
ship_city |
String | Shipping City |
ship_state |
String | Shipping State |
ship_zip |
String | Shipping Zip |
ship_cntry |
String | Shipping Country |
bill_fname |
String | Billing First Name |
bill_lname |
String | Billing Last Name |
bill_email |
String | Billing Email Address |
bill_comp |
String | Billing Company |
bill_phone |
String | Billing Phone Number |
bill_fax |
String | Billing Fax Number |
bill_addr1 |
String | Billing Address Line 1 |
bill_addr2 |
String | Billing Address Line 2 |
bill_city |
String | Billing City |
bill_state |
String | Billing State |
bill_zip |
String | Billing Zip |
bill_cntry |
String | Billing Country |
ship_id |
Number | Shipping Module Used in Shipping Calculations |
ship_data |
String | Shipping Data - Typically Shipping Method Name |
ship_method |
String | Shipping Method Name |
cust_login |
String | Customer Login |
cust_pw_email |
String | Customer Email Password |
business_title |
String | Business Title |
payment_module |
String | Payment Module Name |
source |
String | Source of how the order was placed. Possible Values include “Shopper”, “Subscription”, “User” |
source_id |
Number | The id of the customer, id of Admin user or id of subscription based on how order was placed |
total |
Number | Total |
formatted_total |
String | Formatted Total |
total_ship |
Number | Total Shipping |
formatted_total_ship |
String | Formatted Total Shipping |
total_tax |
Number | Total Tax |
formatted_total_tax |
String | Formatted Total Tax |
total_auth |
Number | Total Authorized |
formatted_total_auth |
String | Formatted Total Authorized |
total_capt |
Number | Total Captured |
formatted_total_capt |
String | Formatted Total Captured |
total_rfnd |
Number | Total Amount Refunded |
formatted_total_rfnd |
String | Formatted Total Amount Refunded |
net_capt |
Number | Net Amount Captured |
formatted_net_capt |
String | Formatted Net Amount Captured |
pend_count |
Number | Pending Item Count |
bord_count |
Number | Backordered Item Count |
note_count |
Number | Note Count |
Related functions#
| Function | Use it to |
|---|---|
Order_Create |
Create an order with its items and charges |
OrderItem_Add |
Add items to the new order |
OrderList_Load_Query |
Find the order to copy |
Order_Update_Customer_Information |
Change the copied bill to and ship to information |
Try in Postman#
In the Miva: JSON API: Authenticated collection, open Orders > Order_Create_FromOrder. See Set Up Postman.