Order Workflows & Queues#
Order Queues#
Order Queues give you the ability to group orders together. For example, you can create an order queue which only shows new orders that have not been shipped. Or an order queue for certain orders which need to be manually reviewed by customer service before being sent to be fulfilled.
You can create an unlimited number of order queues which can both be managed via the admin as well as tied in to the API so any external system can pull orders from a specific queue.
Say for example you want to process all your next day air orders ahead of all others. You can create an order queue specifically for them and leverage an order workflow to automatically put orders in that queue. This way your warehouse team can look at the “Next Day Air” queue first ahead of the other orders which need to be processed that day.
Default Queues#
New & Updated Orders - Keeps track of all new and updated orders for an external API to process
Successfully Retrieved Orders - These are orders which have successfully been pulled into an external system (Order Management, ERP, Accounting, ect)
Managing Order Queues#
Once Order Queues have been setup, you can leverage the Miva admin to view which orders are in each queue and move orders from one queue to another both individually and in bulk.
To see which orders are in each queue its best to use Advanced Search on the orders batch list and set up a Saved Search for each queue.
There is a yes/no flag on each order to determine if an order is in that particular queue.
Also, when editing an individual order you can see which queues it is in and easily add or remove it from an order by selecting the Order Queues link.
Order Workflows#
Order Workflows are a way to setup automated rules to perform some action to an order when an event occurs. For example you can setup a workflow to move all new orders into the “New & Updated Orders” queue. There are 3 key components to an order workflow:
- Trigger - An event which happens in Miva to start to workflow
- Conditions - Conditional statements run against the order level data to determine if an action to should be run.
- Actions - The action to perform if the conditions are true.
Create Workflow#
Each order workflow has a name, active flag and an option setting for “Wait Until True”
Wait Until True#
This settings allow you to automatically have Miva re-check the order at any internal you want for any time period to see if the conditions have been met to run the action. For example say you are creating order in the admin and in our workflow we want all orders with next day air shipping to be moved into the next day shipping queue. However the order create trigger runs immediately after you click new order in the admin. In this case we would want to leverage a Wait Until True setting to have Miva periodically check in the conditions are met. Once we have a shipping method, then we can proceed.
Default Wait Until True
The default settings are to re-check the order every 5 minutes for 60 minutes. Keep in mind that adjusting these settings too high could cause the Wait Until True queue to get extremely large.
Scheduled Task
The “Wait Until True” feature is driven by a scheduled task which runs every minute to re-check all orders in the wait until true queue. This scheduled task is enabled by default in all stores and is called Process Order Workflow Wait Queue
.
Triggers#
Triggers are the fixed events Miva gives you access to tie into based on events which occur in Miva.
Trigger | Description |
---|---|
Order Retrieved | This is called when an external system pulls an order from a queue using the QueueOrderList_Load_Query function. |
Order Acknowledged | This is called when an external API confirms it was able to successfully pull and order from a queue using thee function. |
Order Created | This gets called when an order is placed via the front end by the shopper, in the admin (by a customer service rep) or by a subscription. |
Order Status Change | Called any time the order status changes. |
Order Total Change | Called any time the order total changes. |
Order Shipment Created | Called when a shipment is created. |
Order Shipment Deleted | Called when a shipment is deleted. |
Order Shipment Status Change | Called when a shipment moves from picking to shipped. |
Order Item Created | Called when a new item is added to the order |
Order Item Updated | Called when a item is updated (price, attributes, quantity, etc) |
Order Item Status Change | Called when an item status changes. |
Order Item Deleted | Called when an Item gets deleted. |
Order Return | Called when an RMA is created. |
Order Return Deleted | Called when a RMA is deleted. |
Order Return Status Change | When a return status changes. |
Note
All triggers happen whether the event occurred by the shopper, in the admin, via XML provisioning or the JSON API.
Conditions#
Conditions allow you to create flexible conditional statements to run against the order data. For example, is there is shipping method on the order and and does it equal “Next Day Air”
If the “Wait Until True” option is selected, all orders placed will go into a special internal queue. Miva will then re-check the conditions based on the settings configured.
There are two types of conditions:
- Conditions: Operations against a single data point
- List Conditions: Operations against an array of data (items, options, charges, payment, etc)
A conditional can be nested and chained together to create very custom rules.
The length()
can only be used on Conditions to check the length of an array or field.
Custom Field Syntax#
A common condition may be to check a value of a custom order field. All custom order fields are available in the order workflow module and can be reference in a conditional statement using the following syntax:
order:CustomField_Values:customfields:my_custom_field
Where my_custom_field is the custom order field code you want to run the condition against.
Actions#
The actions are what occur if the conditions are met. Multiple actions can be added to each workflow so it is possible to add an order to a queue, add a note to the order and sent a webhook all within the same workflow.
Action | Description |
---|---|
Add to Queue | Add order to the queue specified |
Move to Queue | Move order from current queue to new queue specified |
Remove from Queue | Remove order from specific queue |
Remove from All Queues | Remove order from all queues |
Add Note | Add note to order |
Set Custom Field | Set a value to a specified custom field |
Webhook (GET) | Send a GET request with the order data in a JSON object to a specified URL |
Webhook (POST) | Send a POST request with the order data in a JSON object to a specified URL |
Webhooks#
Webhooks are a way to have miva push order data to any external API endpoint either as a GET request or a POST request.
The entire order object is sent with a webhook. There is no way to send a partial object.
As of Miva Version 10.00.04, webhooks support http basic authentication
. This allows you to send webhooks to endpoints behind http basic authentication
. Miva allows to configure the credentials on a per webhook basis or use credentials shared across multiple webhooks.
Here is an example order webhook request
{
"id":1001,
"pay_id":0,
"batch_id":0,
"status":0,
"pay_status":0,
"stk_status":0,
"dt_instock":0,
"orderdate":1588976246,
"cust_id":0,
"ship_res":false,
"ship_fname":"Test",
"ship_lname":"Order",
"ship_email":"test@miva.com",
"ship_comp":"Miva",
"ship_phone":"123456789",
"ship_fax":"",
"ship_addr1":"123 Test",
"ship_addr2":"",
"ship_city":"San Diego",
"ship_state":"CA",
"ship_zip":"123456",
"ship_cntry":"US",
"bill_fname":"Test",
"bill_lname":"Order",
"bill_email":"test@miva.com",
"bill_comp":"Miva",
"bill_phone":"123456789",
"bill_fax":"",
"bill_addr1":"123 Test",
"bill_addr2":"",
"bill_city":"San Diego",
"bill_state":"CA",
"bill_zip":"92127",
"bill_cntry":"US",
"ship_id":138,
"ship_data":"Free Shipping",
"ship_method":"Free Shipping",
"cust_login":"",
"cust_pw_email":"",
"business_title":"",
"payment_module":"None",
"source":"shopper",
"source_id":0,
"total":10.00,
"formatted_total":"$10.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":1,
"bord_count":0,
"note_count":1,
"items":[
{
"order_id":1001,
"line_id":2,
"status":0,
"subscrp_id":0,
"subterm_id":0,
"rma_id":0,
"dt_instock":0,
"code":"sample",
"name":"Sample",
"sku":"",
"retail":10.00,
"base_price":10.00,
"price":10.00,
"weight":0.00,
"taxable":true,
"upsold":false,
"quantity":1,
"total":10.00
}
],
"charges":[
],
"coupons":[
],
"discounts":[
],
"payments":[
{
"id":3,
"order_id":1001,
"type":1,
"refnum":"1001",
"amount":10.00,
"formatted_amount":"$10.00",
"available":10.00,
"formatted_available":"$10.00",
"dtstamp":1588976246,
"expires":0,
"pay_id":118,
"pay_secid":0,
"decrypt_status":"not_encrypted",
"description":"Check",
"module":{
"id":118,
"code":"check",
"name":"Check Payment",
"provider":"Miva Merchant",
"api_ver":"5.00",
"version":"9.0001",
"module":"modules\/payment\/check.mvc",
"refcount":1,
"active":true
},
"data":{
"check":"12345"
}
}
],
"notes":[
{
"id":1,
"cust_id":0,
"account_id":0,
"order_id":1001,
"user_id":0,
"notetext":"Automated Workflow: Order moved to queue \"New \u0026 Updated Orders\".",
"dtstamp":1588976246,
"cust_login":"",
"business_title":"",
"admin_user":""
}
],
"CustomField_Values":{
"customfields":{
"order_instructions":"",
"order_ip":"",
"order_ua":""
},
"orderworkflow":{
"new_and_Updated":"1",
"successfully_retrieved_orders":""
}
}
}