Difference between revisions of "Liquid Template Variables - order"

From Spiffy Stores Knowledge Base

 
(74 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The Order variables are exported and made available to Order Confirmation emails and notifications, and to the ''Additional Content & Scripts'' section that is available under '''Preferences -> Checkout & Payment"'.
+
The Liquid template variable '''order''' has the following attributes:
  
== <code>order_name</code> ==
+
== <code>order.id</code> ==
  
The is the name of the order.
+
Returns the unique internal number of the order.
  
By default, the name is formatted as a hash (#) followed by the order number. For example,
+
This is normally only for internal usage.
  
<pre>#01234</pre>
+
== <code>order.customer</code> ==
  
== <code>order_number</code> ==
+
Return the [[Liquid_Template_Variables_-_customer|customer]] who placed this order.
 +
 
 +
== <code>order.email</code> ==
 +
 
 +
Returns the email address associated with the order.
 +
 
 +
== <code>order.currency</code> ==
 +
 
 +
Return the currency used for this order.
 +
 
 +
<pre>
 +
{{ order.currency }} => 'AUD'
 +
</pre>
 +
 
 +
== <code>order.credit</code> ==
 +
 
 +
Return the amount of credit that has been applied to this order from the customer's account credit.
 +
 
 +
== <code>order.cancelled</code> ==
 +
 
 +
Returns true if the order has been cancelled.
 +
 
 +
== <code>order.cancelled_at</code> ==
 +
 
 +
Returns the date and time that the order was cancelled.
 +
 
 +
<pre>
 +
{{ order.cancelled_at | date: "%B %d, %Y %I:%M%p" }}
 +
</pre>
 +
 
 +
== <code>order.cancel_reason</code> ==
 +
 
 +
Returns one of the following cancellation reasons, if the order was cancelled.
 +
 
 +
* Customer changed/cancelled order
 +
* Items unavailable
 +
* Fraudulent order
 +
* Other
 +
 
 +
== <code>order.cancel_reason_label</code> ==
 +
 
 +
Returns one of the following cancellation reasons, if the order was cancelled.
 +
 
 +
* Customer changed/cancelled order
 +
* Items unavailable
 +
* Fraudulent order
 +
* Other
 +
 
 +
== <code>order.created_at</code> ==
 +
 
 +
Returns the date and time that the order was created.
 +
 
 +
<pre>
 +
{{ order.created_at | date: "%B %d, %Y %I:%M%p" }}
 +
</pre>
 +
 
 +
== <code>order.customer_url</code> ==
 +
 
 +
Returns the URL of the customer's account page.
 +
 
 +
<pre>
 +
{{ order.name | link_to: order.customer_url }}
 +
 
 +
=>
 +
 
 +
http://mystore.spiffystores.com/customers/account/orders/cd260181d310e4b13669872e54e76da8
 +
</pre>
 +
 
 +
== <code>order.discounts</code> ==
 +
 
 +
Returns an array of [[Liquid_Template_Variables_-_discount|discounts]] that have been applied to this order.
 +
 
 +
<pre>
 +
{% for discount in order.discounts %}
 +
  Code: {{ discount.code }}
 +
  Savings: {{ discount.savings | money }}
 +
{% endfor %}
 +
 
 +
=>
 +
 
 +
Code: SELLOUT10
 +
Savings: $45.50
 +
</pre>
 +
 
 +
== <code>order.discount_price</code> ==
 +
 
 +
Returns the total amount of discounts that have been applied to this order.
 +
 
 +
== <code>order.financial_status</code> ==
 +
 
 +
Returns the financial status of an order. The possible values are:
 +
 
 +
* pending
 +
* authorized
 +
* paid
 +
* partially_paid
 +
* refunded
 +
* partially_refunded
 +
* voided
 +
 
 +
== <code>order.financial_status_label</code> ==
 +
 
 +
Returns the display text for the financial status of an order. The possible values are:
 +
 
 +
* Pending
 +
* Paid
 +
* Partially Paid
 +
* Cancelled
 +
 
 +
== <code>order.fulfilment_status</code> ==
 +
 
 +
Returns the display text for the financial status of an order. The possible values are:
 +
 
 +
* unshipped
 +
* partial
 +
* shipped
 +
 
 +
== <code>order.fulfilment_status_label</code> ==
 +
 
 +
Returns the display text for the fulfillment status of an order. The possible values are:
 +
 
 +
* Unshipped
 +
* Partial
 +
* Shipped
 +
 
 +
== <code>order.line_items</code> ==
 +
 
 +
== <code>order.name</code> ==
 +
 
 +
Returns the name of the order using the format set in the ''Standards & formats'' section of the Preferences settings of your Spiffy Stores toolbox.
 +
 
 +
<pre>
 +
{{ order.name }} => #100234
 +
</pre>
 +
 
 +
== <code>order.order_number</code> ==
  
 
This is the number of the order.
 
This is the number of the order.
  
<pre>1234</pre>
+
<pre>
 +
{{ order.order_number }} => 1234
 +
</pre>
 +
 
 +
== <code>order.shipping_address</code> ==
 +
 
 +
Returns the shipping [[Liquid_Template_Variables_-_address|address]] of the order.
 +
 
 +
== <code>order.billing_address</code> ==
 +
 
 +
Returns the billing [[Liquid_Template_Variables_-_address|address]] of the order.
 +
 
 +
== <code>order.shipping_methods</code> ==
 +
 
 +
== <code>order.shipping_price</code> ==
 +
 
 +
Returns the amount of shipping included in the order.
 +
 
 +
== <code>order.subtotal_price</code> ==
  
== <code>customer</code> ==
+
Returns the total amount of the order less discounts.
  
Returns a [[ Liquid Template Variables - customer | customer object ]] containing the email and name of the customer.
+
This amount will not include any additional taxes or shipping costs.
 +
== <code>order.tags</code> ==
 +
Return an array of all the tags assigned to this order.
  
== <code>shop_name</code> ==
+
== <code>order.taxes_included</code> ==
  
Returns the name of your shop.
+
== <code>order.tax_lines</code> ==
  
== <code>subtotal_price</code> ==
+
Returns an array of [[Liquid_Template_Variables_-_tax_line|tax_line]] objects for the order.
  
Returns the sub-total value of the order.
+
<pre>
 +
{% for tax_line in order.tax_lines %}
 +
  Tax ({{ tax_line.title }} {{ tax_line.rate | times: 100 }}%): {{ tax_line.price | money }}
 +
{% endfor %}
  
== <code>total_price</code> ==
+
=>
  
Returns the total of the order, which is the sub-total plus tax and shipping, if applicable.
+
Tax (GST 10.0%): $25
 +
</pre>
  
== <code>tax_price</code> ==
+
== <code>order.tax_price</code> ==
  
Returns the amount of tax on the order.
+
Returns the total amount of tax for the order.
  
== <code>shipping_price</code> ==
+
== <code>order.included_tax_price</code> ==
  
Returns the amount of shipping included in the order.
+
Returns the amount of taxes included in the order subtotal price. Included taxes occur when the amount of tax is included as part of an item's price as opposed to taxes which are added to the item's price.
 +
 
 +
== <code>order.total_price</code> ==
 +
 
 +
Returns the total of the order, which is the subtotal plus tax and shipping, if applicable, and includes any credits.
 +
 
 +
If the order total includes taxes which are not applicable for export orders, then these taxes are not included in the total price for the order.
 +
 
 +
== <code>order.amount_due</code> ==
 +
 
 +
Returns the total of the order, which is the subtotal plus tax and shipping, if applicable, excluding any credits.
 +
 
 +
If the order total includes taxes which are not applicable for export orders, then these taxes are not included in the total price for the order.
 +
 
 +
== <code>order.surcharge_price</code> ==
 +
 
 +
Returns the amount of any payment surcharges that have been applied to this order.
 +
 
 +
== <code>order.surcharge_rate</code> ==
 +
 
 +
Returns the payment surcharge rate that has been applied to the order.
 +
 
 +
<pre>
 +
{{ order.surcharge_rate }} => 0.025
 +
</pre>
 +
 
 +
== <code>order.surcharge_description</code> ==
 +
 
 +
Returns a description of the payment surcharge that has been applied to this order.
  
== <code>discount_price</code> ==
+
<pre>
 +
{{ order.surcharge_description }} => 'Surcharge on payment by Visa card (1.0%)'
 +
</pre>
  
Returns the amount of any discounts that have been applied to the order.
+
== <code>order.transactions</code> ==
  
== <code>discount_code</code> ==
+
== <code>order.unique_gateway</code> ==
  
Returns the discount code that was used, if any.
 
  
 
== <code>gateway</code> ==
 
== <code>gateway</code> ==
Line 55: Line 243:
 
Returns a the shipping method used for the order.
 
Returns a the shipping method used for the order.
  
== <code>shipping_address</code> ==
 
  
Returns a [[ Liquid Template Variables - address | shipping address object ]].
+
== <code>order_quantity</code> ==
  
== <code>billing_address</code> ==
+
Returns the total number of items in the order.
 
 
Returns a [[ Liquid Template Variables - address | billing address object ]].
 
  
 
== <code>line_items</code> ==
 
== <code>line_items</code> ==
Line 67: Line 252:
 
Returns an array of Line_Item objects.
 
Returns an array of Line_Item objects.
  
== <code>note</code> ==
+
== <code>fulfilled_line_items</code> ==
 +
 
 +
Returns an array of fulfilled Line_Item objects.
 +
 
 +
== <code>unfulfilled_line_items</code> ==
 +
 
 +
Returns an array of Line_Item objects that have not been fulfilled.
 +
 
 +
== <code>order.note</code> ==
  
 
Returns the note that was attached to the order.
 
Returns the note that was attached to the order.
  
== <code>attributes</code> ==
+
== <code>order.attributes</code> ==
  
Returns any attributes which where attached to the order.
+
Returns any attributes which where attached to the order when it was created.
 +
 
 +
Each of the keys refers to the unique name that was specified cart form input field that was created in the '''Cart.liquid''' template.
 +
 
 +
See the [[Asking your customer for additional information#Cart_Attributes|Cart Attributes]] section.
  
 
Example usage:
 
Example usage:
  
<pre>{{ attributes.gift-note }}</pre>
+
<pre>
 +
{{ order.attributes.gift_note }}
 +
{{ order.attributes.child_name }}
 +
</pre>
 +
 
 +
All of the attributes can also be enumerated, providing both the key and the value for each attribute.
 +
 
 +
<pre>
 +
{% for attribute in order.attributes %}
 +
  <p>Key: {{ attribute.first }} - Value: {{ attribute.last }}</p>
 +
{% endfor %}
 +
</pre>
 +
 
 +
== <code>order.metafields</code> ==
 +
 
 +
Return the [[Liquid Template Variables - metafields|metafields]] for the order.
 +
 
 +
Metafields can only be managed using the Spiffy Stores API.
 +
 
 +
== Further Reference ==
 +
 
 +
* [[Liquid Basics]]
 +
* [[Liquid Tag Reference]]
 +
* [[Liquid Filter Reference]]
 +
* [[Liquid Variable Reference]]
 +
* [[Liquid Paginate Tag|Pagination ]]

Latest revision as of 10:33, 9 February 2023

The Liquid template variable order has the following attributes:

order.id

Returns the unique internal number of the order.

This is normally only for internal usage.

order.customer

Return the customer who placed this order.

order.email

Returns the email address associated with the order.

order.currency

Return the currency used for this order.

{{ order.currency }} => 'AUD'

order.credit

Return the amount of credit that has been applied to this order from the customer's account credit.

order.cancelled

Returns true if the order has been cancelled.

order.cancelled_at

Returns the date and time that the order was cancelled.

{{ order.cancelled_at | date: "%B %d, %Y %I:%M%p" }}

order.cancel_reason

Returns one of the following cancellation reasons, if the order was cancelled.

  • Customer changed/cancelled order
  • Items unavailable
  • Fraudulent order
  • Other

order.cancel_reason_label

Returns one of the following cancellation reasons, if the order was cancelled.

  • Customer changed/cancelled order
  • Items unavailable
  • Fraudulent order
  • Other

order.created_at

Returns the date and time that the order was created.

{{ order.created_at | date: "%B %d, %Y %I:%M%p" }}

order.customer_url

Returns the URL of the customer's account page.

{{ order.name | link_to: order.customer_url }}

=>

http://mystore.spiffystores.com/customers/account/orders/cd260181d310e4b13669872e54e76da8

order.discounts

Returns an array of discounts that have been applied to this order.

{% for discount in order.discounts %}
  Code: {{ discount.code }}
  Savings: {{ discount.savings | money }}
{% endfor %}

=>

Code: SELLOUT10
Savings: $45.50

order.discount_price

Returns the total amount of discounts that have been applied to this order.

order.financial_status

Returns the financial status of an order. The possible values are:

  • pending
  • authorized
  • paid
  • partially_paid
  • refunded
  • partially_refunded
  • voided

order.financial_status_label

Returns the display text for the financial status of an order. The possible values are:

  • Pending
  • Paid
  • Partially Paid
  • Cancelled

order.fulfilment_status

Returns the display text for the financial status of an order. The possible values are:

  • unshipped
  • partial
  • shipped

order.fulfilment_status_label

Returns the display text for the fulfillment status of an order. The possible values are:

  • Unshipped
  • Partial
  • Shipped

order.line_items

order.name

Returns the name of the order using the format set in the Standards & formats section of the Preferences settings of your Spiffy Stores toolbox.

{{ order.name }} => #100234

order.order_number

This is the number of the order.

{{ order.order_number }} => 1234

order.shipping_address

Returns the shipping address of the order.

order.billing_address

Returns the billing address of the order.

order.shipping_methods

order.shipping_price

Returns the amount of shipping included in the order.

order.subtotal_price

Returns the total amount of the order less discounts.

This amount will not include any additional taxes or shipping costs.

order.tags

Return an array of all the tags assigned to this order.

order.taxes_included

order.tax_lines

Returns an array of tax_line objects for the order.

{% for tax_line in order.tax_lines %}
  Tax ({{ tax_line.title }} {{ tax_line.rate | times: 100 }}%): {{ tax_line.price | money }}
{% endfor %}

=>

Tax (GST 10.0%): $25

order.tax_price

Returns the total amount of tax for the order.

order.included_tax_price

Returns the amount of taxes included in the order subtotal price. Included taxes occur when the amount of tax is included as part of an item's price as opposed to taxes which are added to the item's price.

order.total_price

Returns the total of the order, which is the subtotal plus tax and shipping, if applicable, and includes any credits.

If the order total includes taxes which are not applicable for export orders, then these taxes are not included in the total price for the order.

order.amount_due

Returns the total of the order, which is the subtotal plus tax and shipping, if applicable, excluding any credits.

If the order total includes taxes which are not applicable for export orders, then these taxes are not included in the total price for the order.

order.surcharge_price

Returns the amount of any payment surcharges that have been applied to this order.

order.surcharge_rate

Returns the payment surcharge rate that has been applied to the order.

{{ order.surcharge_rate }} => 0.025

order.surcharge_description

Returns a description of the payment surcharge that has been applied to this order.

{{ order.surcharge_description }} => 'Surcharge on payment by Visa card (1.0%)'

order.transactions

order.unique_gateway

gateway

Returns the name of the payment gateway that was used.

shipping_method

Returns a the shipping method used for the order.


order_quantity

Returns the total number of items in the order.

line_items

Returns an array of Line_Item objects.

fulfilled_line_items

Returns an array of fulfilled Line_Item objects.

unfulfilled_line_items

Returns an array of Line_Item objects that have not been fulfilled.

order.note

Returns the note that was attached to the order.

order.attributes

Returns any attributes which where attached to the order when it was created.

Each of the keys refers to the unique name that was specified cart form input field that was created in the Cart.liquid template.

See the Cart Attributes section.

Example usage:

{{ order.attributes.gift_note }}
{{ order.attributes.child_name }}

All of the attributes can also be enumerated, providing both the key and the value for each attribute.

{% for attribute in order.attributes %}
  <p>Key: {{ attribute.first }} - Value: {{ attribute.last }}</p>
{% endfor %}

order.metafields

Return the metafields for the order.

Metafields can only be managed using the Spiffy Stores API.

Further Reference