Conditions in Shopify Flow
Conditions continue a workflow when certain rules are met, such as the start of an if-then statement. When you set a condition, you choose criteria from fields in the GraphQL Admin API (such as product.title), a logical operator (such as equal to), and a value to check against (such as Blue jeans). When a workflow evaluates a condition, Flow checks the value defined in the workflow against the value returned for your store, then displays the results in the workflow run. To better understand the fields and values available for defining conditions, learn how to preview store data.
Learn more about understanding the basics of conditions.
On this page
Data types used with Flow
When you set a condition, you choose a criteria from the fields available in the Admin API and Flow evaluates against the value returned for your store.
Flow supports the following kinds of data:
- Float: Float values are numbers with a decimal amount. For example, 4.25.
- Integer: Integer values are whole numbers that don't have a decimal amount. For example, 42.
- Date: Date values are numerical representation of the date. For example, 01012021.
- String: String values are text. Comparisons using string values aren't case sensitive.
- Boolean: Boolean values are either true or false.
- Enum: Enum values are sets of data that allow for a variable to be a set of predefined constants.
Logical operators
Logical operators define how your condition is applied. Conditions can check simple properties such as whether an order's total is above a certain amount, or whether a customer accepts marketing. Logical operators can also check for more complex properties.
Operators can be either field-level operators, such as equal to or not equal to, or list operators, such as at least one of or none of.
Field-level operators
Field-level operators are used to compare 2 values. Flow can use the following operators:
| Operator | Description | Example |
|---|---|---|
| Equal to | Compares values to check whether they're the same. |
The value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.If the total discounts of the order equal 50 exactly, then the condition is true. |
| Not equal to | Compares values to check whether they aren't the same. |
The value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.If the total discounts of the order don't equal 50 exactly, then the condition is true. |
| Greater than and Greater than or equal to | Compares values to check whether the first value is greater than, or greater than or equal to, the second value. |
The value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.If the value total discounts of the order is 137, then the condition is true, because 137 is greater than 50. |
| Less than and Less than or equal to | Compares values to check whether the first value is less than, or less than or equal to, the second value. |
The value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.If the total discounts of the order is 47, then the condition is true, because 47 is less than or equal to 50. |
| At least one of | Checks whether the field is equal to any value in the provided list. The values must be entered individually and followed by the enter key (similar to tags). Using on a blank array results in a false evaluation. |
The value for order.lineitem.product.title is compared to: pineapple, guava, kiwi.If the line item product title is guava, then the condition is true, because "guava" is included in the list that you provided. |
| Not any of | Checks whether the field is not equal to any of the values in the provided list. |
The value for order.lineitem.product.title is compared to: pineapple, guava, kiwi.If the line item product title is raspberry, then the condition is true, because "raspberry" isn't included in the list that you provided. |
| Includes | Compares values to check whether any of the first value input includes the data in the second value input. |
The value for order.lineitem.product.title is compared to: berry.If the line item product title is strawberry, then the condition is true, because "berry" is included in "strawberry". |
| Does not include | Compares values to check whether any of the first value input does not include the data in the second value input. |
The value for order.lineitem.product.title is compared to: berry.If the line item product title is apple, then the condition is true, because "berry" isn't included in "apple". |
| Starts with | Compares values to check whether the first value starts with the data in the second value. |
The value for order.shippingAddress.country is compared to: United.If the country for the order's shipping address is United Kingdom, then the condition is true, because "United Kingdom" starts with "United". |
| Does not start with | Compares values to check whether the first value does not start with the data in the second value. |
The value for order.shippingAddress.country is compared to: United.If the country for the order's shipping address is Canada, then the condition is true, because "United Kingdom" doesn't start with "Canada". |
| Ends with | Compares values to check whether the first value ends with the data in the second value. |
The value for order.lineitems.product.title is compared to: pie.If the line item product title is key lime pie, then the condition is true, because "key lime pie" ends with "pie". |
| Does not end with | Compares values to check whether the first value does not end with the data in the second value. |
The value for order.lineitems.product.title is compared to: pie.If the line item product title is chocolate cake, then the condition is true, because "chocolate cake" doesn't end with "pie". |
Null or empty operators
| Operator | Description | True/False Condition |
|---|---|---|
| Empty or does not exist | Checks if a field is empty (has no value) or does not exist (is null). |
Returns true when the field is empty or null, and false if it is present.
|
| Not empty and exists | Checks if a field is present and isn't empty or null. | Returns true when the field isn't empty and exists, false when it is empty. |
List operators
List operators are combined with field-level operators to allow you to check conditions on data included in lists.
As in the "at least one" example, you might want to check if an order contains a specific product (located in order.lineItems) with a specific tag (a list under order.lineItems.product.tags). In both cases, the example uses the at least one of list operator.
Flow provides 3 operators for working with lists: At least one of, None of, and All of.
| Operator | Description | Example usage |
|---|---|---|
| At least one of | Checks whether any item in the list matches the specified condition. Returns true if any item in the list matches. If the list is empty or no items match, then returns false. | Check if an order contains a product with a specific tag using At least one of order line items.product.tags is equal to tagname. |
| None of | Checks that none of the items in the list match the specified condition. Returns true if none of the items match the condition. If the list is empty, then returns true. | Check if a product doesn't have the tag presale using None of product tags is equal to presale.A common mistake is to try to negate the operator by using is not equal to. Using this double-negative, None of product tags is not equal to presale, makes the condition both hard to understand and invalid.
|
| All of | Checks that all items in the list match the specified condition. Returns true if every item in the list matches the condition. | Check if all items in an order have a specific product vendor called Acme using All of order line items have a product.vendor equal to Acme. |
Ordering conditions
You can create workflows that have multiple conditions, each of which can result in different actions. The order of the conditions matters. The check for conditions starts at the beginning of the workflow and proceeds systematically through each condition. The check stops when a condition is met.
This example uses multiple conditions to check whether a customer is eligible for a loyalty program based on the total amount that they have spent in the store. The conditions are checked in the order in which they are displayed:
- If the total price is greater than $1000 and the customer agrees to accept marketing, then tag them with the
Goldtag. - If the total price is less than $1000 but more than $500 and the customer agrees to accept marketing, then tag them with the
Silvertag. - If the total price is less than $500 but more than $200 and the customer agrees to accept marketing, then tag them with the
Bronzetag.

Combining multiple criteria in one condition
When building a condition, you can set several criteria. You can choose how this separate criteria should be combined to determine whether the overall condition is true or false.
If all criteria are met
Selecting AND results in a true response only if every criteria that you set is true.
For example, you create a workflow to tag customers that are located in Canada and spend more than $500 on a single order.

The workflow tags the customer only if the customer is located in Canada and they spend more than $500 in the order. If either of these conditions are false, then the customer isn't tagged.
If any criteria are met
Selecting OR results in a true response if any one of the criteria that you set is true.
For example, you create a workflow to tag orders with a risk recommendation of Cancel or Investigate. As long as one of those conditions are true, the order is tagged.

Static and dynamic data in conditions
Typically, the second value in a condition is a static, manually-entered value (such as product.title == "your title"). This value remains the same every time the workflow runs.
You can also use dynamic values if the field for the second value displays a icon. Dynamic values are drawn from your store data every time the workflow runs. To use a dynamic value, click the
icon and select the value you want to check against. Dynamic values aren't available for all fields.
For example, you create a workflow that tags an order if the country in the order's billing address matches the country in its shipping address.

In this example, both the first and the second values are drawn from your store's data, rather than manually specifying a static string to check against for the second value. If the country in the billing address provided by the customer is the same as the country the customer provided in the shipping address, then the condition is true, and the order is tagged.
You might occasionally need to use dynamic data that is the wrong type. For example, you might need to compare a number stored as a string with another number. In this case, you can use the Run code option to convert the data to the correct type.
Templates
Most templates in the template library contain a condition.
Example conditions
Check if at least one item in a list matches a condition
This example displays a typical condition that checks if at least one item in a list matches a certain value.
In this case, the condition checks if one of the products in an order has a tag of presale. To build this condition, you would choose order / lineItems / product / tags. By default, Flow chooses at least one of as the logical operator:

The at least one of parts are list operators and are used to handle matching across multiple list items. The is equal to part is a field-level operator that determines whether a single list item matches.
Check if none of the items in a list match a condition
This example displays a typical condition that checks if none of the items in a list match a certain value. One common problem to consider is that lists can be empty. When a list is empty, the condition will be handled by the list operator (in this case none of).
In this case, the condition checks if none of the product tags is equal to foo:

The condition will return true if (1) there are no product tags or (2) none of the tags are foo. Otherwise, it will return false.
Check if an item in a list matches multiple criteria
This example displays a typical condition that checks if a least one item in a list matches two separate criteria.
In this case, the condition checks if one of the products in an order has a tag of presale and if it has a productType of clothing.

To build this condition, you should:
- Choose order / lineItems / product / tags for the first criteria.
- Choose to Add criteria for same item on the lineItems list. Note: Choosing the wrong list item here is a common mistake.
- Choose lineItems_item as the top level object and then product / productType` for the second criteria. Note: Choosing the wrong object here is also a common mistake.
- Choose AND to combine the two criteria.
- Enter the values
presaleandclothingfor the two criteria.