Email Variable Reference dev

From Spiffy Stores Knowledge Base

Revision as of 10:37, 28 October 2022 by Shawn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Emails sent out from your shop are rendered using Liquid. Liquid is Spiffy Stores' simple, easy-to-use programming language. It's the same programming language that our themes are built on.

To edit your email templates, follow this tutorial. Here is a list of liquid email templates which you can customise from your shop admin:

  • Order Confirmation
  • New Order Notification
  • New Order Notification (mobile)
  • Shipping Confirmation
  • Shipping Update
  • Draft Order
  • Abandoned Order
  • Gift Card


All email templates in your admin have access to the properties of their corresponding order:

In this article

Order variables

Many properties of an order are available directly using Liquid, in email templates and in Additional Content & Scripts.

The properties of an order are available in the following templates:

  • Order Confirmation
  • New Order Notification
  • New Order Notification (mobile)
  • Shipping Confirmation
  • Shipping Update
  • Additional Content & Scripts


Reminder

Unlike most other Liquid objects, the order object itself is not referenced by name in any of the email templates or in Additional Content & Scripts. So instead of using

{{ order.shipping_method.title }}

in, for example, your Order Confirmation email template, you would simply use

{{ shipping_method.title }}

.


id A system wide unique ID of the order for internal use. Use this e.g. to generate a link to the order in the admin section of your store. For example, in your New Order Notification template you would place:
<a href="{{ shop.url }}/admin/orders/{{ id }}">View order</a>
email The email associated with the order.
name Typically this is a pound symbol followed by the order_number, e.g. Order #1004.
order_name Same as name.
order_number Shop unique number of the order, e.g. 1004, without the pound # prefix, or any prefix or suffix added to the order ID by the Store owner in your store preferences.
created_at The date and time the customer created the order, e.g. 2009-05-30T17:43:51+02:00. You can format this using the date filter.

transaction.

tax_price Taxes of all the items in the order combined.
tax_lines Taxes broken up by 'level' of taxation:
{% for tax_line in tax_lines %} 
  {{ tax_line.title }} ({{ tax_line.rate_percentage }}%) : {{ tax_line.price | money_with_currency }} 
{% endfor %}
tax_line.title The name of the tax, e.g. GST or VAT.
tax_line.price The amount.
tax_line.rate The rate. It will return 0.175 if it is 17.5%.
tax_line.rate_percentage The tax rate in human readable form. It will return 17.5 if the rate is 0.175.
customer Customer object containing the attributes of the customer output.
billing_address The billing address.
billing_address.first_name First name of the customer.
billing_address.last_name Last name of the customer.
billing_address.company Company name for billing.
billing_address.phone Phone number from the billing address.
shop_name Name of your store.
shop.phone Your store's phone number.
subtotal_price Subtotal of the order.
discounts_amount Amount of the discount applied by all discounts (e.g. +$5.00).
discounts_savings Amount of the savings caused by all discounts (e.g. -$5.00).
discounts A list of discounts.
total_price Total of the order (subtotal + tax + shipping).
financial_status The current payment status. One of: nil, 'pending', 'authorized', 'paid', 'voided', 'refunded'.
requires_shipping (boolean) Returns true if there is at least one item in the order that requires shipping.
shipping_method.title The Shipping rate name e.g. “Standard Shipping”.
shipping_method.price Same as shipping_price below.
shipping_price The shipping price. Example:
{{ shipping_price | money }}
shipping_address The shipping address.
shipping_address.company Company name for shipping address.
shipping_address.company Company name for shipping address.
shipping_address.phone Phone number from the shipping address.
line_items List of all Line Items in the order.
item_count A sum of all the items' quantities.
fulfillment_status The current fulfillment status of the order. One of: 'unfulfilled', 'partial', 'fulfilled'.
note The note which is attached to the order. The note can be obtained from the customer and/or edited in the order detail screen in your admin interface.
attributes Any attributes which were attached to the order. Example:
{{ attributes.gift-note }}
referring_site Contains the url of the referrer that brought the customer to your store. Example:
http://www.google.com/?s=great+products
landing_site Contains the path of the landing site the customer used. This is the first page that the customer saw when he/she reached the store.

Example: /products/great-product?ref=my-tracking-token

landing_site_ref Looks at the landing site and extracts a reference parameter from it. Reference parameters can be: ref, source, r.

If the landing_site was /products/great-product?ref=my-tracking-token, then the landing_site_ref will be my-tracking-token. You can accomplish a certain action if your ref is equal to a certain value:

{% if landing_site_ref == 'my-tracking-token' %}
My action...
{% endif %}
cancelled (boolean) Returns true if the order has been cancelled.
cancelled_at The time when the order was cancelled.
cancel_reason The reason selected when cancelling the order. One of: 'inventory', 'customer', 'fraud', 'other'.
has_high_risks? Returns true if the order has high risk
unique_gateways Returns a list of unique payments gateways on an order.

Line_item properties

Each line in the list of line_items has the following properties. See the default templates for example usage.

line.title The name of the product followed by a dash followed by the name of the variant. The variant name is not included when it is “Default Title”.
line.price The price for a single item.
line.quantity Quantity for that item.
line.line_price The price multiplied by the quantity for that item.
line.sku SKU of the product.
line.grams Weight of a single item.
line.vendor Vendor for the item.
line.requires_shipping (boolean) Returns true if the variant for the item has the checkbox 'Require a shipping address' checked on the product page.
line.taxable (boolean) Returns true if the variant for the item has the checkbox 'Charge taxes on this product' checked on the product page.

Fulfillment properties

These additional properties are available on the Shipping Confirmation and Shipping Update email templates.

The Shipping confirmation and Shipping update are used to notify your customers that some or all items in their order have been successfully fulfilled, or updated with new shipping information.

fulfillment.fulfillment_line_items A list of Fulfillment_line_items to be fulfilled.
fulfillment.item_count A sum of all the items' quantities. The total number of items being fulfilled.
fulfillment.tracking_company The company doing the tracking.
fulfillment.tracking_numbers A list of tracking numbers.
fulfillment.tracking_urls A list of tracking URLs.
fulfillment.requires_shipping (boolean) Returns true if this fulfillment request requires shipping.

Discounts in email templates

discounts

is a list of discounts applied to the order. Currently, there can only be one discount so this list contains only 1 element, but it may be possible to apply many discount codes to the same order in the future.

You can retrieve the discount object from the list with:

{% assign discount = discounts.first %}

To show the discount code and amount applied to the order, you'll use:

{% if discounts %}Discounts ({{ discounts.first.code }}) : {{ discounts_savings | money_with_currency }}{% endif %}

Each

discount

element has the following Liquid properties:

title The name of this discount.
code The code the customer has to input to apply for this discount.
amount Amount of the savings this discount causes (usually same as discounts_amount, because there is only one discount object).
savings Amount of the discount this discount applies (usually same as discounts_savings, because there is only one discount object).