Difference between revisions of "Email Variable Reference dev"

From Spiffy Stores Knowledge Base

 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
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.
 
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 customize from your shop admin:
+
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
 
* Order Confirmation
Line 8: Line 8:
 
* Shipping Confirmation
 
* Shipping Confirmation
 
* Shipping Update
 
* Shipping Update
 +
* Draft Order
 +
* Abandoned Order
 +
* Gift Card
  
  
Line 37: Line 40:
  
  
id
+
<html>
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 shop. For example, in your New Order Notification template you would place:
+
<style type="text/css">
<a href="{{ shop.url }}/admin/orders/{{ id }}">View order</a>
+
table.reference th {
email
+
background-color: #FAFAFA;
The email associated with the order.
+
padding: 6px;
name
+
text-align: left;
Typically this is a pound symbol followed by the order_number, e.g. Order #1004.
+
vertical-align: top;
order_name
+
font-family: Monaco,Consolas,"Lucida Console",monospace;
Same as name.
+
font-size: 13px;
order_number
+
color: #575757;
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 shop-owner in his shop preferences.
+
width: 160px;
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.
+
table.reference td {
transaction Notifications have access to every transaction property. Please see our Transaction API documentation here for a full list of the properties.
+
padding: 6px;
tax_price
+
}
Taxes of all the items in the order combined.
+
</style>
tax_lines
+
</html>
Taxes broken up by 'level' of taxation:
+
{| class="reference"
{% for tax_line in tax_lines %} {{ tax_line.title }} ({{ tax_line.rate_percentage }}%) : {{ tax_line.price | money_with_currency }} {% endfor %}
+
!id
tax_line.title
+
|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:
The name of the tax, e.g. QST or VAT.
+
<pre><a href="{{ shop.url }}/admin/orders/{{ id }}">View order</a></pre>
tax_line.price
+
|-
The amount.
+
!email
tax_line.rate
+
|The email associated with the order.
The rate. It will return 0.175 if it is 17.5%.
+
|-
tax_line.rate_percentage
+
!name
The tax rate in human readable form. It will return 17.5 if the rate is 0.175.
+
|Typically this is a pound symbol followed by the order_number, e.g. Order #1004.
customer
+
|-
Customer object containing the attributes of the customer output.
+
!order_name
billing_address
+
|Same as name.
The billing address.
+
|-
billing_address.first_name
+
!order_number
First name of the customer.
+
|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.
billing_address.last_name
+
|-
Last name of the customer.
+
!created_at
billing_address.company
+
|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.
Company name for billing.
+
transaction.
billing_address.phone
+
|-
Phone number from the billing address.
+
!tax_price
shop_name
+
|Taxes of all the items in the order combined.
Name of your store.
+
|-
shop.phone
+
!tax_lines
Your store's phone number.
+
|Taxes broken up by 'level' of taxation:
subtotal_price
+
<pre>
Subtotal of the order.
+
{% for tax_line in tax_lines %}  
discounts_amount
+
  {{ tax_line.title }} ({{ tax_line.rate_percentage }}%) : {{ tax_line.price | money_with_currency }}  
Amount of the discount applied by all discounts (e.g. +$5.00).
+
{% endfor %}
discounts_savings
+
</pre>
Amount of the savings caused by all discounts (e.g. -$5.00).
+
|-
discounts
+
!tax_line.title
A list of discounts.
+
|The name of the tax, e.g. GST or VAT.
total_price
+
|-
Total of the order (subtotal + tax + shipping).
+
!tax_line.price
financial_status
+
|The amount.
The current payment status. One of: nil, 'pending', 'authorized', 'paid', 'voided', 'refunded'.
+
|-
requires_shipping
+
!tax_line.rate
(boolean) Returns true if there is at least one item in the order that requires shipping.
+
|The rate. It will return 0.175 if it is 17.5%.
shipping_method.title
+
|-
The Shipping rate name e.g. “Standard Shipping”.
+
!tax_line.rate_percentage
shipping_method.price
+
|The tax rate in human readable form. It will return 17.5 if the rate is 0.175.
Same as shipping_price below.
+
|-
shipping_price
+
!customer
The shipping price.
+
|Customer object containing the attributes of the customer output.
Example: {{ shipping_price | money }}
+
|-
shipping_address
+
!billing_address
The shipping address.
+
|The billing address.
shipping_address.company
+
|-
Company name for shipping address.
+
!billing_address.first_name
shipping_address.company
+
|First name of the customer.
Company name for shipping address.
+
|-
shipping_address.phone
+
!billing_address.last_name
Phone number from the shipping address.
+
|Last name of the customer.
line_items
+
|-
List of all Line Items in the order.
+
!billing_address.company
item_count
+
|Company name for billing.
A sum of all the items' quantities.
+
|-
fulfillment_status
+
!billing_address.phone
The current fulfillment status of the order. One of: 'unfulfilled', 'partial', 'fulfilled'.
+
|Phone number from the billing address.
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.
+
!shop_name
attributes
+
|Name of your store.
Any attributes which were attached to the order.
+
|-
Example: {{ attributes.gift-note }}
+
!shop.phone
referring_site
+
|Your store's phone number.
Contains the url of the referrer that brought the customer to your store.
+
|-
Example: http://www.google.com/?s=great+products
+
!subtotal_price
landing_site
+
|Subtotal of the order.
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.
+
|-
 +
!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: <pre>{{ shipping_price | money }}</pre>
 +
|-
 +
!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: <pre>{{ attributes.gift-note }}</pre>
 +
|-
 +
!referring_site
 +
|Contains the url of the referrer that brought the customer to your store.
 +
Example: <pre>http://www.google.com/?s=great+products</pre>
 +
|-
 +
!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
 
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.
+
!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 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:
 +
<pre>
 
{% if landing_site_ref == 'my-tracking-token' %}
 
{% if landing_site_ref == 'my-tracking-token' %}
 
My action...
 
My action...
 
{% endif %}
 
{% endif %}
cancelled
+
</pre>
(boolean) Returns true if the order has been cancelled.
+
|-
cancelled_at
+
!cancelled
The time when the order was cancelled.
+
|(boolean) Returns true if the order has been cancelled.
cancel_reason
+
|-
The reason selected when cancelling the order. One of: 'inventory', 'customer', 'fraud', 'other'.
+
!cancelled_at
has_high_risks?
+
|The time when the order was cancelled.
Returns true if the order has high risk
+
|-
unique_gateways
+
!cancel_reason
Returns a list of unique payments gateways on an order. For example, if someone paid with a Visa, a Mastercard, and cash, the returned list would be "shopify_payments, cash".
+
|The reason selected when cancelling the order. One of: 'inventory', 'customer', 'fraud', 'other'.
location (POS only)
+
|-
Displays the physical location of the order. There are several location properties available, listed here. You can configure locations in the Locations area of the admin.
+
!has_high_risks?
fulfilled_line_items (deprecated)
+
|Returns true if the order has high risk
List of Line Items which have been fulfilled.
+
|-
unfulfilled_line_items (deprecated)
+
!unique_gateways
List of Line Items which have not been fully fulfilled.
+
|Returns a list of unique payments gateways on an order.  
 +
|}
  
 
==Line_item properties==
 
==Line_item properties==
Line 197: Line 264:
 
!line.taxable
 
!line.taxable
 
|(boolean) Returns true if the variant for the item has the checkbox 'Charge taxes on this product' checked on the product page.
 
|(boolean) Returns true if the variant for the item has the checkbox 'Charge taxes on this product' checked on the product page.
|-
 
!line.applied_discounts (POS orders only)
 
|List of discounts applied to this item (each discount has the title, code, amount, savings and type properties).
 
 
|}
 
|}
  
 
==Fulfillment properties==
 
==Fulfillment properties==
  
These additional properties are available on the Shipping Confirmation, Shipping Update and Fulfillment Request email templates.
+
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.
 
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.
  
The Fulfillment Request email template is used for any custom fulfillment service defined in your shop admin. To add a custom fulfillment service, go to the Settings > Shipping pages and scroll down to the "Fulfillment/Dropshipping" section.
+
<html>
 
+
<style type="text/css">
service_name
+
table.reference th {
The name of the custom service as defined in the Settings > Shipping page. (Fulfillment Request only)
+
background-color: #FAFAFA;
fulfillment.fulfillment_line_items
+
padding: 6px;
A list of Fulfillment_line_items to be fulfilled.
+
text-align: left;
fulfillment.item_count
+
vertical-align: top;
A sum of all the items' quantities. The total number of items being fulfilled.
+
font-family: Monaco,Consolas,"Lucida Console",monospace;
fulfillment.tracking_company
+
font-size: 13px;
The company doing the tracking.
+
color: #575757;
fulfillment.tracking_numbers
+
width: 131px;
A list of tracking numbers.
+
}
fulfillment.tracking_urls
+
table.reference td {
A list of tracking URLs.
+
padding: 6px;
fulfillment.requires_shipping
+
}
(boolean) Returns true if this fulfillment request requires shipping.
+
</style>
items_to_fulfill (deprecated)
+
</html>
List of Line Items that are to be fulfilled by this particular Custom fulfillment service. (Fulfillment Request only)
+
{| class="reference"
items_to_fulfill_count (deprecated)
+
!fulfillment.fulfillment_line_items
The total number of items to be fulfilled by this request. (Fulfillment Request only)
+
|A list of Fulfillment_line_items to be fulfilled.
Fulfillment_line_item properties
+
|-
 
+
!fulfillment.item_count
Each fulfillment_line in the list of fulfillment_line_items has the following properties.
+
|A sum of all the items' quantities. The total number of items being fulfilled.
 
+
|-
fulfillment_line.line_item
+
!fulfillment.tracking_company
The line_item being fulfilled. This has access to all the line_item's properties.
+
|The company doing the tracking.
fulfillment_line.quantity
+
|-
The quantity of the line item that is being fulfilled.
+
!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 in email templates==

Latest revision as of 10:37, 28 October 2022

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).