Conditions in Shopify Flow
In Shopify Flow, conditions determine whether or notan actionis taken after a trigger starts a workflow. When you set a condition, you choose avalue taken from data in your store, alogical operator, and manually set a value to check against.
On this page
Data types used with Flow
The first value in any Flow condition is data taken from your store, and is drawn from theGraphQL Admin API.
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:布尔值或真或假。
- Enum: Enum values are sets of data that allow for a variable to be a set of predefined constants.
Logical operators used in Flow
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.
Flow can use the following operators:
- Equal to
- Not equal to
- Greater than and Greater than or equal to
- Less than and Less than or equal to
- Any of
- Not any of
- Includes
- Does not include
- Starts with
- Does not start with
- Ends with
- Does not end with
Equal to
Equal to比较s values to see whether they're the same. In the following example, the value fororder.currentTotalDiscountsSet.shopMoney.amount
is retrieved from your store data and compared to the second value, 50.
If the first value equal to 50, then the condition is true. The order is cancelled.
Not equal to
Not equal to比较s values to see whether they are not the same. In the following example, the value fororder.currentTotalDiscountsSet.shopMoney.amount
is retrieved from your store data and compared to the second value, 50.
If the first value is equal to 93, then the condition is true. The order is cancelled.
Greater than and Greater than or equal to
Greater thanandGreater than or equal to比较values to see whether the first value is greater than, or greater than or equal to, the second value. In the following example, the value fororder.currentTotalDiscountsSet.shopMoney.amount
is retrieved from your store data and compared to the second value, 50.
If the value taken from your store is 137, then the condition is true, because 137 is greater than 50. The order is cancelled.
Less than and Less than or equal to
Less thanandLess than or equal to比较values to see whether the first value is less than, or less than or equal to, the second value. In the following example, the value fororder.currentTotalDiscountsSet.shopMoney.amount
is retrieved from your store data and compared to the second value, 50.
If the value taken from your store is 47, then the condition is true, because 47 is less than or equal to 50. The order is cancelled.
Any of
Any of比较值数组的数据是否the first value input contains any of the data in the second value input. The values to be checked must be entered individually and followed by the enter key. UsingAny ofon a blank array results in a false evaluation. In the following example, the value fororder.lineitem.product.title
is retrieved from your store data and compared to the second set of values: pineapple, guava, kiwi.
If the value taken from your store is guava, then the condition is true, because guava is included in the array pineapple, guava, kiwi. The order is cancelled.
Not any of
Not any of比较值数组的数据是否the first value input does not contain any of the data in the second value input. The values to be checked must be entered individually and followed by the enter key. In the following example, the value fororder.lineitem.product.title
is retrieved from your store data and compared to the second set of values: pineapple, guava, kiwi.
If the value taken from your store is raspberry, then the condition is true, because raspberry is not included in the array pineapple, guava, kiwi. The order is cancelled.
Includes
Includes比较s values to see whether any of the first value input includes the data in the second value input. In the following example, the value fororder.lineitem.product.title
is retrieved from your store data and compared to the second value, scrape.
If the value taken from your store data is skyscraper, then the condition is true, because the exact string scrape is included in the string skyscraper. The order is cancelled.
Does not include
Does not include比较s values to see whether any of the first value input does not include the data in the second value input. In the following example, the value fororder.lineitem.product.title
is retrieved from your store data and compared to the second value, scrape.
If the value taken from your store data is scrap-metal, then the condition is true, because the exact string scrape is not included in the string scrap-metal. The order is cancelled.
Starts with
Starts with比较s values to see whether the first value starts with the data in the second value. In the following example, the value fororder.shippingAddress.country
is retrieved from your store data and compared to the second value, United.
If the value taken from your store is United Kingdom, then the condition is true, because the string United starts the string United Kingdom. The order is cancelled.
Does not start with
Does not start with比较s values to see whether the first value does not start with the data in the second value. In the following example, the value fororder.shippingAddress.country
is retrieved from your store data and compared to the second value, United.
If the value taken from your store is Canada, then the condition is true, because the string Canada does not start the string United Kingdom. The order is cancelled.
Ends with
Ends with比较s values to see whether the first value ends with the data in the second value. In the following example, the value fororder.lineitems.product.title
is retrieved from your store data and compared to the second value, last-available.
If the value taken from your store is athletic socks last-available, then then the condition is true, because the string athletic socks last-available ends with the string last-available. The order is cancelled.
Does not end with
Does not end with比较s values to see whether the first value does not end with the data in the second value. In the following example, the value fororder.lineitems.product.title
is retrieved from your store data and compared to the second value, last-available.
If the value taken from your store is athletic socks new, then the condition is true because the string athletic socks new does not end with the string last-available. The order is cancelled.
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.
Meeting multiple conditions
When you set a condition, you can set several criteria and determine whether Flow will consider the condition true if all conditions or met, or if any one of the conditions is met.
If all conditions are met
SelectingIf all conditions are metresults 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 is not tagged.
If any conditions are met
SelectingIf any conditions are metresults in a true response if any one of the criteria that you set is true.
For example, you create a workflow to tag orders that are considered high or medium risk.
The workflow tags the order if it is either high or medium risk. As long as one of those conditions are true, the order is tagged.
Combining conditions and actions
You can combine conditions together to make one large condition. When conditions are combined, all conditions must be met for the whole condition to be true. If any condition is not met, then the whole condition is false. In the following example, the customer must accept marketing materials and the total price of the order must meet a certain threshold.
Similarly, you can combine actions together so that multiple actions can run. 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. In the example above, the following conditions are checked in the order in which they appear:
- If the total price is greater than $1000 and the customer agrees to accept marketing, then tag them with the Gold tag.
- If the total price is less than $1000 but more than $500 and the customer agrees to accept marketing, then tag them with the Silver tag.
- If the customer has spent more than $200 and the customer agrees to accept marketing, then tag them with the Bronze tag.
Static and dynamic data in conditions
Typically, the second value in a condition is a static, manually-entered value. 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>
symbol. Dynamic values are drawn from your store data every time the workflow runs. To use a dynamic value, click the>
symbol 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.