Template variable examples

The following list contains examples of messages and notes that use template variables.

  • In the following example, the title of the discontinued product will appear in the message:
Discontinued product {{product.title}} has just hit an inventory level of 0.
  • In the following example, the title of variant will appear in the message:
Please pause all ad campaigns involving {{product_variant.title}}.
  • In the following example, the customer's name and email address along with the total of their last order will appear in the message:
Please send a personal thank you note to {{order.customer.firstName}}({{order.customer.email}}) for placing a recent order for  {{order.totalPrice}}
  • In the following example, the title of the product will appear in the message:
Please reorder {{product.title}}. Email owner@store.com to verify that they've received the purchase order.
  • In the following example, the order ID will appear in the message:
{{order.id}} has been cancelled due to high risk.
  • In the following example, the order number and the customer's name and email address will appear in the message:
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!
  • In the following example, the name of the customer, their email address, and the total price of their last order will appear in the message along with a link to the order in your Shopify admin:
Please send a personal thank you note to
{{order.customer.firstName}} ({{order.customer.email}}) for placing a recent order for $ {{order.totalPrice}}

View order: https://store.myshopify.com/admin/orders/{{order.id}}

For Loop examples

You can use for loops in your messages to iterate through a list of objects, such as line items. Text fields that support template variables also support for loops and the forloop object.

Here's an example that uses a for loop to list the SKUs and quantities of all the products ordered:

Order includes:
{% for a in order.lineItems %}
  SKU: {{a.sku}} ( {{a.quantity}} ), 
{% endfor %}

When the message is sent, the for loop code is replaced with the list of SKUs:

Order includes:
  8987097979 50
  8877778887 3
  888998898B 1

In this example, the for loop is used to list all the line items ordered:

Order summary: <br />
{% for a in order.lineItems %}
title: {{a.title}},
Price (per unit): ${{a.originalUnitPrice}},
SKU: {{a.sku}},
Quantity: {{a.quantity}} <br/>
{% endfor %} 

Ship to: <br />
{{order.shippingAddress.name}}  <br/>
{{order.shippingAddress.address1}}  <br/>
{{order.shippingAddress.address2}}  <br/>
{{order.shippingAddress.city}}  <br/>
{{order.shippingAddress.province}}  <br/>
{{order.shippingAddress.zip}}  <br/>
{{order.shippingAddress.country}}  <br/>

Want to discuss this page?

Visit the Shopify Community

Ready to start selling online with Shopify?

Try it free