Difference between revisions of "Email Variable Reference dev"

From Spiffy Stores Knowledge Base

Line 211: Line 211:
 
==Discounts in email templates==
 
==Discounts in email templates==
  
<code>discounts</code> 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.
+
<pre>discounts</pre> 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:
 
You can retrieve the discount object from the list with:

Revision as of 08:31, 14 October 2014

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:

  • Order Confirmation
  • New Order Notification
  • New Order Notification (mobile)
  • Shipping Confirmation
  • Shipping Update


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

In this article

  • Order variables
  • Line_item properties
  • Fulfillment properties
  • Discounts in email templates


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 Fulfillment Request 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 Template:Order.shipping method.title in, for example, your Order Confirmation email template, you would simply use Template: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 shop. For example, in your New Order Notification template you would place: <a href="Template:Shop.url/admin/orders/Template: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 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. transaction Notifications have access to every transaction property. Please see our Transaction API documentation here for a full list of the properties. 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 %} Template:Tax line.title (Template:Tax line.rate percentage%) : Template:Tax line.price {% endfor %} tax_line.title The name of the tax, e.g. QST 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: Template:Shipping price 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: Template: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. For example, if someone paid with a Visa, a Mastercard, and cash, the returned list would be "shopify_payments, cash". 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. fulfilled_line_items (deprecated) List of Line Items which have been fulfilled. unfulfilled_line_items (deprecated) List of Line Items which have not been fully fulfilled.


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

These additional properties are available on the Shipping Confirmation, Shipping Update and Fulfillment Request 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 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.

service_name The name of the custom service as defined in the Settings > Shipping page. (Fulfillment Request only) 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. items_to_fulfill (deprecated) List of Line Items that are to be fulfilled by this particular Custom fulfillment service. (Fulfillment Request only) items_to_fulfill_count (deprecated) The total number of items to be fulfilled by this request. (Fulfillment Request only) Fulfillment_line_item properties

Each fulfillment_line in the list of fulfillment_line_items has the following properties.

fulfillment_line.line_item The line_item being fulfilled. This has access to all the line_item's properties. fulfillment_line.quantity The quantity of the line item that is being fulfilled.


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 (Template:Discounts.first.code) : Template:Discounts savings{% 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).