Get order data
In workflows that require order data, you can use the Get order data action to retrieve order information from your store.
On this page
Configuration
Fields
The Get order data action contains the following fields, which are used to build the query:
Field | Description |
---|---|
Sort data by | Required. The parameters by which the data returned by the search query is sorted. |
Maximum number of results | Required. The maximum amount of results that can be returned by the search query that you select. You can return up to 100 at a time. |
Query | Required. Choose from common queries or select Advanced to create your own. |
Query String
This is an example query for getting orders that were updated in the last day:
The updated_at
variable is a filter available on the Orders query and can be used multiple times or combined with other variables. The scheduledAt
Liquid variable is available on workflows that used the Scheduled time trigger. The date_minus
Liquid tag is a special Flow tag that allows you to subtract time from a date.
When querying data, it's helpful to know:
- List of available order filters
- Queries must follow a certain syntax
- Query field values are not always documented. In some cases, the values can be found by looking at the API docs. Alternatively, you can often find the field values in the URLs in the Admin when you filter. For example, to find some Order query values, filter the Orders page in the Admin, and then check the URL.
- You can run or test a query in your shop by using the Shopify GraphiQL app.
- Be mindful of what happens if your query fails. Often the API will return all results (instead of none).
Returned data
All Get data actions return a list of anywhere from 0 and 100 resources. Depending your use case, you might want to use this data in various ways:
- If you need to handle each list item individually, such as to add a tag for each, then you can use the For each action.
- If you need to aggregate data, such as count how many results were returned, then you can use the Count or Sum actions.
- If you need output the list, such as send an email with all the items, then you can use returned data directly in susbsequent actions.
To access the returned data in steps that follow this action, use the variable named Get order data, which is a list of orders. You can use this variable in both conditions and actions. For example, you can send the list of orders in a Send internal email action like this:
Triggers
You can use this action in any workflow, including the Scheduled time trigger. In a workflow that uses the Scheduled time trigger, the workflow starts at a time that you've specified, rather than as a result of an event. Because there is no specific event in your store or from an app that starts the workflow, there is no data automatically included.
API details
Templates
Cancel orders for frequent returners
Cancels orders from customers who have returned items five or more times in the last six months. It fetches order data, counts returns, and cancels the current order, issuing a refund and restocking items. This template can be used to: reduce losses from habitual returners, streamline order management by preemptively handling potential returns, and maintain profitability by discouraging excessive returns. View template
Cancel orders if customer placed more than 5 orders today
Cancels orders if a customer places more than five orders within a single day. It checks the number of orders placed by a customer in the last 24 hours and cancels any orders exceeding this limit, tagging the customer for potential fraud. View template
Hold fulfillment orders for customers with chargebacks
When an order is ready to fulfill, the workflow retrieves any orders from the same customer within the past 60 days that have a chargeback. If any such orders exist, it holds fulfillment on each shipment and send an internal email to notify your operations. View template
Hold fulfillments if a customer placed multiple orders in 24 hours
Check to see if a customer has placed multiple orders within a 24 hour period. If true, hold the fulfillments and consolidate shipping. View template
Hold orders if customer placed more than 1 order in last 24 hours
When an order is created, check if customer placed any other orders in the last 24 hours. If so, place all orders on hold. View template
Send a notification when Order volume is less than 10 in last hour
Sends an order heartbeat notification. Every hour, get up to 10 orders that were created, and count them. If less than 10, send a notification via Email. Uses the Schedule time, Get order data, and Count steps. View template
Send email summary of all orders to Online Store in the last day
Every day, gets orders for the last day, and sends an email summary with those that were placed on the online store. View template
Send email summary with all unfulfilled orders older than 2 days
Get a daily summary of all of your unfulfilled orders that are older than 2 days, making use of schedules, get order data, count, and sum. View template
Tag and send a daily summary of late fulfillments
Every day, tag and send a daily email summary that counts the total number and dollar value of all orders that miss a 2 day shipping guarantee. View template
Tag customers that have a chargeback
Every hour, this workflows gets orders with chargebacks and adds a tag to the customer for the order. Makes use of scheduled time trigger, get order data, and for each loop. View template
Tag unfulfilled orders older than 2 days
Every day, the workflow gets all unfulfilled orders older than 2 days and it adds a tag to the order. View template
Use tags to segment customers based on their orders for last 6 months
When a new order is created, get the customer's order total and order count for the last 6 months, and then add tags to the customer. Makes use of Get order data, Count, Sum. View template