Flow Automation: Querying Orders in Batch
You can use the Batch query order action in Flow Automation to retrieve a targeted list of orders based on filters such as customer email, creation time range, payment or fulfillment status, and more. This lets you drive downstream steps—like cancelling unpaid orders, tagging in-progress orders, or sending notifications—without manually searching in the admin, helping your team automate routine reviews and follow-ups with confidence.
This guide explains when to use the action, how to test it end to end, and provides a practical example for automating communications and updates.
| Note: The action is read-only and returns up to 100 matching orders per run. |
When to Use the Batch Query Order Action
Use the Batch query order action when:
- You need historical order data that isn't available from the trigger alone.
- You want to check a customer's past orders before deciding what to do with their current one.
- You need a list of orders to feed into a Count or Sum action later in the same workflow.
| Note: This article covers only the Batch query orders action. For the complete workflow it's used in, see "Flow Automation: Building a Workflow to Detect Repeat Return Abuse." |
Field Descriptions
| Field | Description |
| Query Conditions |
Filters applied when running a batch search:
For fields that support it, you can also write the filter as an advanced query instead of selecting values individually. Only one field per query action can use this option, and it must be enabled for that field before it appears in Flow — contact your SHOPLINE account manager if you don't see it. |
| Sort By | Sort results by order creation time: Most recently created order (descending) or Earliest order created (ascending). |
| Maximum Result Limit | Returns up to 100 orders per run. |
Writing an Advanced Query for Order Filters
For fields that support it, you can write the Query conditions filter as a single advanced query string instead of selecting values one at a time. This lets you combine several conditions — such as a time range, a specific customer, and a return status — into one filter.
|
Example query: created_at:>'{{ "now" | date_minus("6 months") }}' AND customer_id:{{customer.id}} AND return_status:returned |
This example retrieves orders created within the last 6 months, placed by the customer on the current order, that have a return status of returned.
| Note: Only one field per query action can use an advanced query, and the exact fields and operators available depend on what's enabled for your store. Confirm supported syntax with your SHOPLINE account manager before relying on a custom query in production. |
Supported Triggers
You can add the Batch query orders action to workflows started by the following triggers. Click on any trigger name to view its setup instructions:
- Scheduled Time
- Bulk Order Operation
- Order Created
Example Use Case
Here is a practical example of using the Batch query order action to automatically tag unpaid orders for follow-up:
- Trigger: Order creation trigger
- Delay: 5 minutes
-
Action: Batch query order
- Query Condition: Specific Order IDs
- Result Sorting: Most recently created order
- Quantity to keep: 100
- Condition: If payment status is unpaid
- Action: Cancel Order
Available Templates
Here is a ready-to-use template that incorporates this action. Click the template to view or apply it:
- Tag incomplete orders: On a daily or weekly schedule, run Batch query order to retrieve up to 100 orders with status Processing, then add tags so your team can quickly identify and handle exceptions. You can customize the delay to match your process for managing and tracking these orders.