Order in email templates and Additional Content & Scripts
From Shopify Wiki
Many properties of an order are available directly using Liquid, in email templates and in Additional Content & Scripts.
Note: Unlike most other Liquid objects, the order object itself is not referenced by name in any of the email templates. It is not referenced by name either in Additional Content & Scripts. So instead of using {{ order.shipping_method }} in e.g. your Order Confirmation email template, you would simply use {{ shipping_method }}.
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
Order Properties
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 shop.
For example, in your New Order Notification template you would place:
<a href="{{ shop.url }}/admin/orders/{{ id }}">View order</a>
Returns 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 shop-owner in his shop 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.
payment
The first successful authorization or sale transaction for this order. This includes the gateway reference showing up on the payment provider side to reconcile your transaction name with the Order on the Shopify side.
payment.created_at
The date and time the customer first successfully authorized or paid this order.
payment.name
The name of this transaction created by Shopify sent to the payment provider, e.g. "c12345678.1" if the first transaction was successful or "c12345678.2" if only the second transaction was successful.
payment.amount
The amount in your shop currency that was either paid or authorized in this transaction.
payment.authorization
The authorization token used to make this payment, this is a unique identifier created by the payment provider.
payment.receipt
The low level payment details passed to Shopify by the payment provider.
payment_details
payment_details.credit_card_company
The type of credit card used, e.g. Visa or American Express (empty when the order hasn't been payed with credit card)
payment_details.credit_card_number
The last four digits of a credit card number preceded by x's, e.g. XXXX-XXXX-XXXX-1234
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 %}
title
The name of the tax, eg. QST or VAT
price
The amount
rate
The rate. It will return 0.175 if it is 17.5%
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 email and name of the client.
customer.accepts_marketing
Returns true or false based on if customer checked the "I want to receive occasional emails..." checkbox or not.
customer.email
Email of the customer
customer.name
Name of the customer
shop_name
Name of your shop
subtotal_price
Subtotal of the order
total_price
Total of the order ( subtotal + tax + shipping )
For example:
Order Total: {{ total_price }}
gateway
Payment method (Payment gateway used)
financial_status
The current payment status. One of: nil, 'pending', 'authorized', 'paid', 'voided', 'refunded'
requires_shipping
Returns true if there is at least one item in the order that requires shipping, and returns false otherwise
shipping_method
ShippingMethod object
shipping_price
Shipping price
shipping_address
Shipping Address object
billing_address
Billing Address object
line_items
Array of all Line Items in the order.
fulfilled_line_items
Array of any Line Items which have been fulfilled (marked as shipped on the order screen).
unfulfilled_line_items
Array of those Line Items which have not yet been fulfilled (marked as shipped on the order screen).
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 note 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
Example:
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
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'
Discounts in email templates
You also have access to the following 3 discount variables but only in email templates:
discounts
Array of discounts applied to the order. Currently, there can only be one discount, so this array 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 Array with
{% assign discount = discounts.first %}
The discount itself has the following Liquid variables:
id
The internal id of that particular discount
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)
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)
total_discounts
(PixelPrinter)
Amount of the savings caused by all discounts (e.g. $5.00)
