Conditions in Shopify Flow

In Shopify Flow, conditions determine whether or not an action is taken after a trigger starts a workflow. When you set a condition, you choose a value taken from data in your store, a logical operator, and manually set a value to check against.

Data types used with Flow

The first value in any Flow condition is data taken from your store, and is drawn from the GraphQL 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: 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 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

Equal to compares values to see whether they're the same. In the following example, the value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.

Example of a workflow that uses the equal to logical operator to cancel an order if the retrieved data is equal to 50

If the first value equal to 50, then the condition is true. The order is canceled.

Not equal to

Not equal to compares values to see whether they are not the same. In the following example, the value for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.

Example of a workflow that uses the not equal to logical operator to cancel an order if the retrieved data is not equal to 50

If the first value is equal to 93, then the condition is true. The order is canceled.

Greater than and Greater than or equal to

Greater than and Greater than or equal to compare 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 for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.

Example of a workflow that uses the greater than logical operator to cancel an order if the retrieved data is greater than to 50

If the value taken from your store is 137, then the condition is true, because 137 is greater than 50. The order is canceled.

Less than and Less than or equal to

Less than and Less than or equal to compare 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 for order.currentTotalDiscountsSet.shopMoney.amount is retrieved from your store data and compared to the second value, 50.

Example of a workflow that uses the less than or equal to logical operator to cancel an order if the retrieved data is less than or equal to 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 compares values in an array of data to see whether 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. Using Any of on a blank array results in a false evaluation. In the following example, the value for order.lineitem.product.title is retrieved from your store data and compared to the second set of values: pineapple, guava, kiwi.

Example of a workflow that uses the any of logical operator to cancel an order if the retrieved data includes pineapple, guava, or 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 compares values in an array of data to see whether 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 for order.lineitem.product.title is retrieved from your store data and compared to the second set of values: pineapple, guava, kiwi.

Example of a workflow that uses the not any of logical operator to cancel an order if the retrieved data does not include pineapple, guava, or 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 compares values to see whether any of the first value input includes the data in the second value input. In the following example, the value for order.lineitem.product.title is retrieved from your store data and compared to the second value, scrape.

Example of a workflow that uses the includes logical operator to cancel an order if the retrieved data includes the string 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 compares 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 for order.lineitem.product.title is retrieved from your store data and compared to the second value, scrape.

Example of a workflow that uses the does not include logical operator to cancel an order if the retrieved data does not include the string 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 compares values to see whether the first value starts with the data in the second value. In the following example, the value for order.shippingAddress.country is retrieved from your store data and compared to the second value, United.

Example of a workflow that uses the starts with logical operator to cancel an order if the retrieved data starts with the string 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 compares values to see whether the first value does not start with the data in the second value. In the following example, the value for order.shippingAddress.country is retrieved from your store data and compared to the second value, United.

Example of a workflow that uses the does not start with logical operator to cancel an order if the retrieved data does not start with the string 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 compares values to see whether the first value ends with the data in the second value. In the following example, the value for order.lineitems.product.title is retrieved from your store data and compared to the second value, last-available.

Example of a workflow that uses the ends with logical operator to cancel an order if the retrieved data ends with the string 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 compares values to see whether the first value does not end with the data in the second value. In the following example, the value for order.lineitems.product.title is retrieved from your store data and compared to the second value, last-available.

Example of a workflow that uses the does not end with logical operator to cancel an order if the retrieved data does not end with the string 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

Selecting If all conditions are met 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.

Example of a workflow that uses the and condition

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

Selecting If any conditions are met 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 that are considered high or medium risk.

Example of a workflow that uses the or condition

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.

Example of a workflow that checks a customer's total spend amount and adds tags

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:

  1. If the total price is greater than $1000 and the customer agrees to accept marketing, then tag them with the Gold tag.
  2. 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.
  3. 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.

Example of a workflow that tags an order using RHS data to check that a customer's billing and shipping country are the same.

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.

Ready to start selling with Shopify?Try it free