Shopify variables for transactional email templates

Learn what variables you can use in your customer and order transactional email templates for Shopify

Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over a week ago

This reference article lists all the variables that are available for Shopify transactional email templates.

To access the customer and order objects for your transactional email sends, you must use the {{ data }} variable.

Use the correct building blocks in your transactional email campaign

When you are building your transactional email campaign, you must place all code in Text building blocks and not Liquid markup building blocks.


Subject line variables

You can't use most variables in your transactional email subject lines. However, there are four that you can use:

  • @FIRSTNAME@

  • @LASTNAME@

  • @ORDER_ID@

  • @ORDER_NUMBER@


Customer variables

You can use any available code for your account confirmation transactional email campaigns.


Customer data variables

The {{ data.customer }} variables are:

Variable

Description of variable

{{ data.customer.id }}

Returns the ID of the customer.

{{ data.customer.email }}

Returns the email address of the customer.

{{ data.customer.first_name }}

Returns the first name of the customer.

{{ data.customer.last_name }}

Returns the last name of the customer.

{{ data.customer.news_letter_subscription }}

  • Returns true if the customer consents to receiving a newsletter subscription.

  • Returns false if the customer hasn’t consented to receiving a newsletter subscription.

{{ data.customer.created_time }}

Returns the date and time a customer was created. For example, 2020-07-08T14:27:44.

{{ data.customer.modified_time }}

Return the date and time a customer was updated. For example, 2020-07-08T14:27:44.

{{ data.customer.company }}

Returns the company name that was left by the customer.

{{ data.customer.phone }}

Returns the phone number of the customer.

{{ data.customer.orders_count }}

Returns the number of total orders a customer has at the time. For example, 2.0.

{{ data.customer.note }}

Returns any notes left by the customer.


Customer billing address variables

The {{ data.customer.billing_address }} variables are:

Variable

Description of variable

{{ data.customer.billing_address.Id }}

Returns the ID of the billing address.

{{ data.customer.billing_address.type }}

Returns the address billing type. For example, billing.

{{ data.customer.billing_address.first_name }}

Returns the first name of the customer.

{{ data.customer.billing_address.last_name }}

Returns the last name of the customer.

{{ data.customer.billing_address.postcode }}

Returns the billing address post code.

{{ data.customer.billing_address.address1 }}

Returns the first line of the billing address.

{{ data.customer.billing_address.address2 }}

Returns the second line of the billing address.

{{ data.customer.billing_address.phone }}

Returns the phone number of the customer.

{{ data.customer.billing_address.city }}

Returns the billing address city.

{{ data.customer.billing_address.country }}

Returns an array of the billing address country.

{{ data.customer.billing_address.country[0].code2 }}

Returns the billing address alpha-2 country code. For example, GB.

{{ data.customer.billing_address.country[0].code3 }}

Returns the billing address alpha-3 country code. For example, GBR.

{{ data.customer.billing_address.country[0].name }}

Returns the billing address country name. For example, United Kingdom.

{{ data.customer.billing_address.state }}

Returns an array of the billing address state.

{{ data.customer.billing_address.state[0].code }}

Returns the billing address state in code format. For example, AZ for Arizona.

{{ data.customer.billing_address.state[0].name }}

Returns the billing address state in code name format. For example, Arizona.

{{ data.customer.billing_address.company }}

Returns the company name.

{{ data.customer.billing_address.default }}

Returns the default billing address. For example, true or false.

The default customer billing address attribute stores addresses that a customer enters where one is the default.


Customer shipping address variables

The {{ data.customer.shipping_address }} variables are:

Variable

Description of variable

{{ data.customer.shipping_address.Id }}

Returns the customer shipping address ID. For example, 8.

{{ data.customer.shipping_address.type }}

Returns the customer shipping address type. For example, shipping.

{{ data.customer.shipping_address.first_name }}

Returns the customer shipping address first name.

{{ data.customer.shipping_address.last_name }}

Returns the customer shipping address last name.

{{ data.customer.shipping_address.postcode }}

Returns the customer shipping address post code.

{{ data.customer.shipping_address.address1 }}

Returns the first line of the customer shipping address.

{{ data.customer.shipping_address.address2 }}

Returns the second line of the customer shipping address.

{{ data.customer.shipping_address.phone }}

Returns the customer shipping phone number.

{{ data.customer.shipping_address.city }}

Returns the customer shipping address city.

{{ data.customer.shipping_address.country }}

Returns an array of the customer shipping address country.

{{ data.customer.shipping_address.country[0].code2 }}

Returns the customer shopping address country in version two format. For example, GB.

{{ data.customer.shipping_address.country[0].code3 }}

Returns the customer shipping address country in version three format. For example, GBR.

{{ data.customer.shipping_address.country[0].name }}

Returns the customer shipping address country name. For example, United Kingdom.

{{ data.customer.shipping_address.state }}

Returns an array of the customer shipping address state.

{{ data.customer.shipping_address.state[0].code }}

Returns the customer shipping address state in code format. For example, AZ for Arizona.

{{ data.customer.shipping_address.state[0].name }}

Returns the customer shipping address state code name. For example, Arizona.

{{ data.customer.shipping_address.company }}

Returns the customer company name that’s used for shipping details.

{{ data.customer.shipping_address.default }}

Returns the customer shipping address default option. For example, true or false.


Order variables

You can use any of the available codes for your order confirmation and other order-related transactional email campaigns.


Order data variables

The {{ data.order }} variables are:

Variable

Description of variable

{{ data.order.id }}

Returns the order ID.

{{ data.order.email }}

Returns the email address of the customer that places the order.

{{ data.order.purchase_date }}

Returns the date and time the customer purchases an order. For example, 2020-07-08T14:33:57Z.

{{ data.order.order_subtotal }}

Returns the order subtotal.

{{ data.order.base_subtotal_incl_tax }}

Returns the order subtotal and includes the tax.

{{ data.order.discount_amount }}

Returns any order discount amounts.

{{ data.order.order_total }}

Returns the order total.

{{ data.order.payment }}

Returns the order payment method. For example, bank deposit.

{{ data.order.delivery_method }}

Returns the order delivery method. For example, flat rate.

{{ data.order.delivery_total }}

Returns the order delivery total.

{{ data.order.currency }}

Returns the order currency. For example, GBP.

{{ data.order.order_status }}

Returns the order status. For example, awaiting payment.

{{ data.order.coupon_code }}

Returns any order coupon codes that were used.

{{ data.order.store_name }}

Returns the store name where the order was placed.

{{ data.order.source }}

Returns the source where the order was placed. For example, eBay and Checkout API.

{{ data.order.fulfillment_status}}

Returns the status of the order. For example, fulfilled.

{{ data.order.payment_status}}

Returns the status of the order payment. For example, pending.


Order billing address variables

The {{ data.order.billing_address }} variables are:

Variable

Description of variable

{{ data.order.billing_address.Id }}

Returns the order order billing address ID.

{{ data.order.billing.address.type }}

Returns the order type. For example, billing.

{{ data.order.billing_address.first_name }}

Returns the first name that’s used for the billing address.

{{ data.order.billing_address.last_name }}

Returns the last name that’s used for the billing address.

{{ data.order.billing_address.billing_postcode }}

Returns the post code that’s used for the billing address.

{{ data.order.billing_address.billing_address_1 }}

Returns the first line of the billing address.

{{ data.order.billing_address.billing_address_2 }}

Returns the second line of the billing address.

{{ data.order.billing_address.phone }}

Returns the phone number.

{{ data.order.billing_address.billing_city }}

Returns the billing address city.

{{ data.order.billing_address.billing_country }}

Returns the billing address country.

{{ data.order.billing_address.state.code }}

Returns the billing address state code. For example, AZ for Arizona.

{{ data.order.billing_address.state.name }}

Returns the billing address state name. For example, Arizona.

{{ data.order.billing_address.company }}

Returns the company name.

{{ data.order.billing_address.fax }}

Returns the fax number.

{{ data.order.billing_address.default }}

Returns the default billing address. For example, true or false.

The default order billing address attribute stores addresses that a customer enters where one is the default.

{{ data.order.billing_address.email }}

Returns the billing email address.


Order delivery address variables

The {{ data.order.delivery_address }} variables are:

Variable

Description of variable

{{ data.order.delivery_address }}

Returns the delivery address.

{{ data.order.delivery_address.Id }}

Returns the delivery ID.

{{ data.order.delivery_address.type }}

Returns the delivery type. For example, shipping.

{{ data.order.delivery_address.first_name }}

Returns the first name.

{{ data.order.delivery_address.last_name }}

Returns the last name.

{{ data.order.delivery_address.delivery_postcode }}

Returns the delivery address post code.

{{ data.order.delivery_address.delivery_address_1 }}

Returns the first line of the delivery address.

{{ data.order.delivery_address.delivery_address_2 }}

Returns the second line of the delivery address.

{{ data.order.delivery_address.phone }}

Returns the phone number.

{{ data.order.delivery_address.delivery_city }}

Returns the delivery address city.

{{ data.order.delivery_address.delivery_country }}

Returns the delivery address country. For example, United States.

{{ data.order.delivery_address.state.code }}

Returns the deliver address state code. For example, AZ for Arizona.

{{ data.order.delivery_address.state.name }}

Returns the delivery address state name. For example, Arizona.

{{ data.order.delivery_address.company }}

Returns the company name.

{{ data.order.delivery_address.fax }}

Returns the fax number.

{{ data.order.delivery_address.default }}

Returns the default order delivery address. For example, true or false.

The default order delivery address attribute stores addresses that a customer enters where one is the default.

{{ data.order.delivery_address.email }}

Returns the email address.


Order product variables

The {{ data.order.products }} variables are:

Variable

Description of variable

{{ data.order.products }}

Lists the line item products in the order as an array.

{{ data.order.products[x].name }}

Returns the name of the products.

{{ data.order.products[x].price }}

Returns the product unit price.

{{ data.order.products[x].price_inc_tax }}

Returns the product unit price, including the tax.

{{ data.order.products[x].sku }}

Returns the product SKU.

{{ data.order.products[x].qty }}

Returns the quantity of product.

{{ data.order.products[x].url }}

Returns the URL of the product page.

{{ data.order.products[x].image_path }}

Returns the URL of the product image.

You can use a combination of the above variables to create your transactional email template. Here is an example of what you can do:

Hi, {{ data.order.billing_address.first_name }}.

Thanks for your order {{ data.order.id }}!

Your order status is now: {{ data.order.order_status}}.

You've ordered the following products:

Items{% for product in data.order.products %}
{{product.name}}
({{product.sku}}) x
{{product.qty}}
Price:{{product.price_inc_tax}}------------------------------------
---------------------
{% endfor %}

Order shipment variables

Order shipment variables are available for shipping confirmation and shipping update emails. The {{ data.shipment }} variables are:

Variable

Description of variable

{{ data.shipment.id }}

Returns the shipping ID.

{{ data.shipment.order_id }}

Returns the order ID.

{{ data.shipment.tracking_numbers }}

Returns an array of all the tracking numbers available for this shipment.

{{ data.shipment.tracking_numbers[0].carrier_id }}

Returns the ID of the carrier. For example, DHL Service.

{{ data.shipment.tracking_numbers[0].tracking_number }}

Returns the shipment tracking number.

{{ data.shipment.tracking_numbers[0].tracking_url }}

Returns the shipment tracking URL (carrier’s website).


Using webhook raw data for Shopify

You can also use the full JSON data made available by Shopify in the associated webhooks that are used to trigger each transactional email. This data is available in the ##{{ data.raw }} variable.

Learn more about what JSON data can be retrieved for each webhook in Shopify developer documentation.

There are different webhooks that are used for each template:

Transactional email template

Shopify webhook

New account confirmation

customer/create

New order confirmation

orders/create

Shipping confirmation

fulfillments/create

Shipping update

fulfillments/update

Order cancelled

orders/cancelled

Order refunded

refunds/create

With webhooks, you can link to the secured order status page:

Click <a href="{{ data.raw.order_status_url }}"> here </a> to see your 
order status.

You can also display the content of a shipment:

Your order has been partially shipped.
Here is the list of the items included in this shipment:
{% for line_item in data.raw.line_items %}
{{line_item.title}} (
{{line_item.sku}}) x
{{line_item.quantity}}
Price:{{line_item.price}}-----------------------------------------
----------------
{% endfor %}
Did this answer your question?