Order Queues and Order Workflows
- Order Queues
- Managing Order Queues in Admin
- Order Workflows
Order Queues give you the ability to group orders together. For example you can create an order queue which only shows new orders which 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.
There are two default queues which are used for API requests:
- New & Updated Orders - Keeps track of all new and updated orders for an external API to pull from
- Successfully Retrieved Orders - These are orders which have successfully been pulled into an external system (Order Management, ERP, Accounting, ect)
Managing Order Queues in Admin
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.
Once you’ve done the advanced search on the Order Batch List, you can save it for future use:
When editing an individual order you can see which queues it is in and easily add or remove it from an order:
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.
Creating a new Order 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.
Note: 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.
The Wait Unitl 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.
Triggers are the fixed events Miva gives you access to tie into based on events which occur in Miva.
Note: All triggers happen whether the event occured by the shopper, in the admin, via XML provisioning or the JSON API.
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"
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)
Conditional can be nested and chained together to create very custom rules. In the example below we are checking if the length of the order:charges array is greater than 0 (ie Charges exist) and if any of the order charges have a description which contain the text "Next Day Air")
The length() can only be used on Conditions to check the length of an array or field.
Because we have the "Wait Until True" option selected, all orders placed will go into a special internal queue. Miva will then re-check the conditions based on the settings configured. In this case it will re-check the order every 5 minutes for 60 minutes ( 12 times) to see if the conditions described are met.
Custom Field Syntax
A common condition may be to check a value of a custom order field. All custom order fields are avaialble in the order workflow module and can be reference in a conditional statement using the following syntax:
Where my_custom_field is the custom order field code you want to run the condition against.
The actions are what occur if the conditions are met. In this case we want to move the order into a Queue:
Multiple actions can be added to each workflow so its possible to add an order to a queue, add a note to the order and sent a webhook all within the same workflow.
- Add to Queue
- Move to Queue
- Remove from Queue
- Remove from All Queues
- Add Note
- Set Custom Field
- Webhook (GET)
- Webhook (POST)
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, for example just sent the item data.
Here is an example order webhook request