Variables in the new Flow

Variables are placeholders that are replaced with values when a workflow runs. These variables describe the attributes of the customers, orders, and products that are involved in your workflows. For example, there are variables for the order number, order price, customer name, and so on.

The names of most variables are self-describing. For example, the variable that displays the name of the product is {{ product.title }}. When the message is sent, this variable is replaced with the name of the ordered product: Large Coffee Mug.

Adding variables to actions

You can add variables to any text field that contains the Add variable link. Click the Add variable link beneath the relevant field, and then choose a variable from the list.

The variables in the Add variable list are filtered, so that you only see the variables that apply to the trigger that you've chosen. After you choose a variable from the list, it is properly formatted and added to the text box for you.

Flow supports almost all GraphQL Admin API fields.

Liquid variables

If you're a developer with experience writing Shopify Liquid code, then you can use Liquid to write your variables or edit variables that you insert using the Add variable link. To learn more, refer to the Liquid template language reference.

Conditional and iteration tags

You can manually add Liquid variable tags to your workflow messages. You can use these tags to include more information in your messages.

For example, you can use a for loop object to iterate through a list of objects, such as line items for an order. With these tags, you can create messages that contain details, such as the product title, SKU, price, and quantity for each line item in an order, and save your recipients from having to look up this information in your Shopify admin.

Flow supports all Shopify Liquid conditional (or control flow) tags:

https://shopify.dev/api/liquid/tags/control-flow-tags#if

Flow also supports all Shopify Liquid iteration tags:

Filters

Flow supports the following Shopify Liquid filters:

Filters that Shopify Liquid supports in Flow
Filter name Filter type
abs Math
append String
at_least Math
at_most Math
capitalize String
ceil Math
concat Array
date Additional
default Additional
divided_by Math
downcase String
escape String
first Array
floor Math
join Array
last Array
lstrip String
map Array
minus Math
modulo Math
newline_to_br String
plus Math
prepend String
remove String
remove_first String
replace String
replace_first String
reverse Array
round Math
rstrip String
size Array
slice String
sort Array
split String
strip String
strip_html String
strip_newlines String
times Math
truncate String
truncatewords String
uniq Array
upcase String
url_encode String
where Array

Variable examples

For example, you want to create a workflow to send an email to an employee when a customer spends more than $500 on an order. You create a workflow using the Order created trigger, set a condition that is true if the order total is above $500, and use the Send email action. In the Message section of the Send email action, you use the following variables.

Example of variable use to provide customer details.
Input Output
Please send a personal thank you note to {{ order.customer.firstName }} {{ order.customer.lastName }}({{ order.customer.email }}) for placing an order for $ {{ order.totalPriceSet.shopMoney.amount }}. Please send a personal thank you note to Jeanne Dupont (jeanne@example.com) for placing an order for $763.42.

You decide that you need to inform a staff member when product inventory is getting low and an order needs to be placed for more stock. You create a workflow that starts with the Inventory quantity changed trigger, and set a condition that is true if the inventory quantity prior is less than or equal to 10. In the Message section of the Send email action, you use the following variables.

Input Output
Please reorder {{ product.title }}. Email owner@store.com to verify that they've received the purchase order. Please reorder High Waist Leggings - Black. Email owner@example.com to verify that they've received the purchase order.

You want to cancel orders that have a high risk level, but prefer for your staff to manually cancel the order. You create a workflow that starts with the Order created trigger, and set a condition that is true if the risk level of the order is equal to high. In the Message section of the Send email action, you use the following variables.

Example of variable use to provide information on a fraudulent order.
Input Output
Our Shopify store has received an order with a high risk of fraud. We would like to cancel this order right away, before it is sent to production:

{{ order.name }}
{{ order.billingAddress.lastName }}, {{ order.billingAddress.firstName }}
{{ order.email }}

Please confirm the new order status. Thanks!
Our Shopify store has received an order with a high risk of fraud. We would like to cancel this order right away, before it is sent to production:

#1001
Dupont, Jeanne
jeanne@example.com

Please confirm the new order status. Thanks!

For loop examples

When an order is received, it can be useful to send a message that contains the products ordered. You can do this by using for loop, which repeatedly execute a block of code. Text fields that support variables also support for loops and the forloop object.

For example, you want to create a workflow that returns a list of all SKUs and quantities in an order. In the Message section of the Send email action, you use the following variables.

Example of for loop use to provide order information.
Input Output
Order summary:
{% for a in order.lineItems %}
SKU: {{a.sku}} ( {{a.quantity}} ),
{% endfor %}
Order summary:
8987097979 (50)
8877778887 (3)
888998898B (1)

You decide to add more information to the email, including the product name, SKUs, price per item, and the customer's shipping information. In the Message section of the Send email action, you use the following variables.

Example of for loop use to provide more extensive order information.
Input Output
Order summary:
{% for a in order.lineItems %}
Product: {{a.title}}
SKU: {{a.sku}}
Price (per unit): $ {{a.originalUnitPriceSet.shopMoney.amount}}
Quantity: {{a.quantity}}
{% endfor %}
Order summary:
Product: High Waist Leggings - Black
SKU: 8987097979
Price (per unit): $8.49
Quantity: 5
Product: Athletic Socks - Blue
SKU: 888998898B
Price (per unit): $5.61
Quantity: 2

You need to track items sold that are supplied by a specific vendor. In the Message section of the Send email action, you use the following variables and include an if statement in your for loop.

Example of for loop and if statement use to provide order information for specific vendors.
Input Output
Acme product sold:
{% for x in order.lineItems %}
{% if x.vendor == 'acme-vendor' %}
Product name: {{x.title}}
SKU: {{x.sku}}
{% endif %}
{% endfor %}
Acme product sold:
Product name: High Waist Leggings - Black
SKU: 8987097979

Ready to start selling with Shopify?

Try it free