Variables

What is a variable?

Variables are representations of data, and when a workflow runs, variables are replaced with real data. Think of variables as the stand-in for the data you want to use, and once the show begins (we hear you yelling action!) that's when the real data comes in to steal the scene.

Find and Use Variables

Let's begin with an example! Using one of our pre-built templates, Send an SMS message to your customer when their order is delivered. Let's look at the SMS Send Message step. Here, you can see that the Retrieve Order > Customer > Phone variable is used. When this workflow runs, this will be replaced with your customer's actual phone number.

Where do you find the variable that fits the part? You can find the Variables menu by clicking the [<>] icon in the To phone number field. A menu will be displayed on the right-hand side.

In the right-hand menu, feel free to use the search bar for "Phone" to find the Customer Phone variable easily.

Since the variable data comes from an earlier step in the workflow, we'll want to select the step that best fits what we're looking to use for the customer's phone number. You'll notice there are several options. In this example, it's best to select the variable Retrieve Order > Customer > Phone.

Once triggered, the order data will determine the customer's phone number for the SMS notification. For example, if an order is received from Jenny Smith (555-867-5309), the workflow will send a text message to 555-867-5309 when the order is delivered. Jenny, we got your number!

Advanced Variable Use

Next, we're going to get technical about variables you can create without the variable menu.

Using global store settings

Use the {{context.shop.PARAMETER}} variables to pull in settings from your Shopify store. Some common variables:

  • {{context.shop.email}}: Your store's contact email. Set in the General page of your Shopify settings.

  • {{context.shop.domain}}: Your store's url. Example: www.mystore.com if you have a custom domain, mystore.myshopify.com if you have not configured a custom domain.

  • {{context.shop.myshopify_domain}}: Your .myshopify.com domain. Example: mystore.myshopify.com.

  • {{context.shop.name}}: Your store's name. Example: My Store.

Formatting tags with Liquid

Variables are parsed similarly to Shopify's Liquid syntax. This can be useful when you wish to manipulate data before it's processed.

In this example, we replace all tags that contain 'Spring Range' with 'Summer Range'.

1. Select the variable for the product tags.

2. Double-click on the variable to edit it.

Reveal the editable version of the variable.

3. Insert the replace filter to replace all tags that contain 'Spring Range' with 'Summer Range'.

Dates and Times

You can get information about the current date and time by using the {{date:<format>}} variable. For example, if the day of the week today is Tuesday, the variable {{date:D}} will return "Tue".

Additionally, you can format the "Created At" variable to only display the date by using the following variable: {{shopify_order.created_at | slice: 0, 10}}

Now that you know how to find and use variables, you can cast your automation data superstars!

Last updated