Liquid variables

Exporteo makes use of the Liquid template language to transform orders to a desired output format.

The base variable is the order object, or the orders list if you are processing orders in bulk. The order object has the same properties as orders returned by Shopify REST API: https://shopify.dev/docs/admin-api/rest/reference/orders/order

Experteo has the ability to pull additional data related to the processed order when you reference a specific property in the output template.

  • order metafields order.metafields

  • fulfillment orders order.fulfillment_orders

  • customer metafields order.customer.metafields

  • product metafields item.product.metafields

  • variant metafields item.variant.metafields

  • transactions orders.transactions

Billing Address

The mailing address associated with the payment method. This address is an optional field that won't be available on orders that do not require a payment method. It has the following properties:

  • order.billing_address.address1: The street address of the billing address.

  • order.billing_address.address2: An optional additional field for the street address of the billing address.

  • order.billing_address.city: The city, town, or village of the billing address.

  • order.billing_address.company: The company of the person associated with the billing address.

  • order.billing_address.country: The name of the country of the billing address.

  • order.billing_address.country_code: The two-letter code (ISO 3166-1 format) for the country of the billing address.

  • order.billing_address.first_name: The first name of the person associated with the payment method.

  • order.billing_address.last_name: The last name of the person associated with the payment method.

  • order.billing_address.latitude: The latitude of the billing address.

  • order.billing_address.longitude: The longitude of the billing address.

  • order.billing_address.name: The full name of the person associated with the payment method.

  • order.billing_address.phone: The phone number at the billing address.

  • order.billing_address.province: The name of the region (province, state, prefecture, …) of the billing address.

  • order.billing_address.province_code: The two-letter abbreviation of the region of the billing address.

  • order.billing_address.zip: The postal code (zip, postcode, Eircode, …) of the billing address.

Company

B2B orders include order.company variable that represents information about the purchasing company for the order.

  • order.company.id

  • order.company.external_id

  • order.company.name

  • order.company.location_id

  • order.company.location.id

  • order.company.location.external_id

  • order.company.location.name

Discount codes

order.discount_applications an ordered list of discount applications. Each discount application consists of the following properties:

  • allocation_method: The method by which the discount application value has been allocated to entitled lines. Valid values:

    • across: The value is spread across all entitled lines.

    • each: The value is applied onto every entitled line.

    • one: The value is applied onto a single line

  • code: The discount code that was used to apply the discount. Available only for discount code applications.

  • description: The description of the discount application, as defined by the merchant or the Shopify Script. Available only for manual and script discount applications.

  • target_selection: The lines on the order, of the type defined by target_type, that the discount is allocated over. Valid values:

    • all: The discount is allocated onto all lines,

    • entitled: The discount is allocated only onto lines it is entitled for.

    • explicit: The discount is allocated onto explicitly selected lines.

  • target_type: The type of line on the order that the discount is applicable on. Valid values:

    • line_item: The discount applies to line items.

    • shipping_line: The discount applies to shipping lines.

  • title: The title of the discount application, as defined by the merchant. Available only for manual discount applications.

  • type: The discount application type. Valid values:

    • automatic: The discount was applied automatically, such as by a Buy X Get Y automatic discount.

    • discount_code: The discount was applied by a discount code.

    • manual: The discount was manually applied by the merchant (for example, by using an app or creating a draft order).

    • script: The discount was applied by a Shopify Script.

  • value: The value of the discount application as a decimal. This represents the intention of the discount application. For example, if the intent was to apply a 20% discount, then the value will be 20.0. If the intent was to apply a $15 discount, then the value will be 15.0.

  • value_type: The type of the value. Valid values:

    • fixed_amount: A fixed amount discount value in the currency of the order.

    • percentage: A percentage discount value.

A discount application of $5 off with code HIFIVE.

[
    {
        "allocation_method": "across",
        "code": "HIFIVE"
        "target_selection": "all",
        "target_type": "line_item",
        "type": "discount_code",
        "value": "5.0",
        "value_type": "fixed_amount"
    }
]

order.discount_codes contains a list of discounts applied to the order. Each discount object includes the following attributes:

  • amount: The amount that's deducted from the order total. When you create an order, this value is the percentage or monetary amount to deduct. After the order is created, this property returns the calculated amount.

  • code: When the associated discount application is of type code, this property returns the discount code that was entered at checkout. Otherwise this property returns the title of the discount that was applied.

  • type: The type of discount:

    • fixed_amount: Applies amount as a unit of the store's currency. For example, if amount is 30 and the store's currency is USD, then 30 USD is deducted from the order total when the discount is applied.

    • percentage: Applies a discount of amount as a percentage of the order total.

    • shipping: Applies a free shipping discount on orders that have a shipping rate less than or equal to amount. For example, if amount is 30, then the discount will give the customer free shipping for any shipping rate that is less than or equal to $30.

In most cases it's possible to apply only one discount code to a Shopify order. Even though order.discount_codes is a list, you can assume that there will be at most one discount code. Here is a code snippet that returns a discount value or 0 if there was no discount :

Discount: {{ order.discount_codes[0].amount | default: 0 | money }}

Note Attributes

order.note_attributes are custom form fields that let you collect additional information from your customers on the cart page. They appear in the Additional Details section of an order details page. order.node_attributes is a list of objects that consist of name and value , for example:

"note_attributes": [
  {
    "name": "Pickup Date",
    "value": "05/06/2021"
  },
  {
    "name": "Pickup Time",
    "value": "4:30 PM"
  },
]

To get an attribute value by name, you can use the following Liquid expression:

{{ order.note_attributes | where: "name", "Delivery Date" | map: "value" | first }}

Line Items

order.line_items contains the list of order line items. Each line item has the following properties:

  • discount_allocations: An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application.

    • amount: The discount amount allocated to the line in the shop currency.

    • discount_application_index: The index of the associated discount application in the order's discount_applications list.

    • amount_set: The discount amount allocated to the line item in shop and presentment currencies.

  • duties: A list of duty objects, each containing information about a duty on the line item.

  • fulfillable_quantity: The amount available to fulfill, calculated as follows:

    quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity - open_fulfilled_quantity

  • fulfillment_service: The service provider that's fulfilling the item. Valid values: manual, or the name of the provider, such as amazon or shipwire.

  • fulfillment_status: How far along an order is in terms line items fulfilled. Valid values: null, fulfilled, partial, and not_eligible.

  • gift_card: Whether the item is a gift card. If true, then the item is not taxed or considered for shipping charges.

  • grams: The weight of the item in grams.

  • id: The ID of the line item.

  • name: The name of the product variant.

  • options_with_values: An array of selected values from the item's product options. Each option is a key-value pair with option.name as the option and option.value as the option value. Elements in line_item.options_with_values can be displayed using a for loop.

    {% for option in line_item.options_with_values %}
        {{ option.name }}: {{ option.value }}
    {% endfor %}
  • origin_location: The location of the line item’s fulfillment origin.

    • id: The location ID of the line item’s fulfillment origin. Used by Shopify to calculate applicable taxes. This is not the ID of the location where the order was placed. You can use the FulfillmentOrder resource to determine the location an item will be sourced from.

    • country_code: The two-letter code (ISO 3166-1 format) for the country of the item's supplier.

    • province_code: The two-letter abbreviation for the region of the item's supplier.

    • name: The name of the item's supplier.

    • address1: The street address of the item's supplier.

    • address2: The suite number of the item's supplier.

    • city: The city of the item's supplier.

    • zip: The zip of the item's supplier.

  • price: The price of the item before discounts have been applied in the shop currency.

  • price_set: The price of the line item in shop and presentment currencies.

  • product_id: The ID of the product that the line item belongs to.

  • product.description: A stripped description of the product, single line with HTML tags removed.

  • product.featured_image_url: The URL of the main image of the product.

  • product.product_type: The product type. A categorization for the product used for filtering and searching products.

  • product.tags: The list of product tags.

  • properties: An array of custom information for the item that has been added to the cart. Each array element is an object consisting of name and value. Often used to provide product customization options, for example, by the Infinite Options app.

    {{ line_item.properties | where: "name", "Engraving" | map: "value" | first }}
  • quantity: The number of items that were purchased.

  • requires_shipping: Whether the item requires shipping.

  • sku: The item's SKU (stock keeping unit).

  • title: The title of the product.

  • variant_id: The ID of the product variant.

  • variant_title: The title of the product variant.

  • variant.barcode: The barcode of the product variant.

  • variant.harmonized_system_code: The harmonized system code of the item. Also known as the HS tariff code.

  • variant.compare_at_price: The compare at price of the product variant. The value is taken from current product data. If you are exporting historical orders, then the compare at price may not reflect the value that was present when an order was placed.

  • variant.cost: The unit cost of the product variant.

  • variant.country_code_of_origin: The two-letter code of the country of origin.

  • vendor: The name of the item's supplier.

  • taxable: Whether the item was taxable.

  • tax_lines: A list of tax line objects, each of which details a tax applied to the item.

    • title: The name of the tax.

    • price: The amount added to the order for this tax in the shop currency.

    • price_set: The amount added to the order for this tax in shop and presentment currencies.

    • rate: The tax rate applied to the order to calculate the tax price.

    • rate_percentage: The tax rate in percentage format.

  • tip_payment_gateway: The payment gateway used to tender the tip, such as shopify_payments. Present only on tips.

  • tip_payment_method: The payment method used to tender the tip, such as Visa. Present only on tips.

  • total_discount: The total amount of the discount allocated to the line item in the shop currency. This field must be explicitly set using draft orders, Shopify scripts, or the API. Instead of using this field, Shopify recommends using discount_allocations, which provides the same information.

  • total_discount_set: The total amount allocated to the line item in the presentment currency. Instead of using this field, Shopify recommends using discount_allocations, which provides the same information.

The best way to process line items is to use a for loop.

{
    "line_items": [
        {%- for item in order.line_items %} 
        {
            "product_id": {{ item.product_id | json }},
            "variant_id": {{ item.variant_id | json }},
            "sku": {{ item.sku | json }},
            "title": {{ item.title | json }},
            "price": {{ item.price | json }},
            "quantity": {{ item.quantity | json }},
            "total_price": {{item.price | times: item.quantity | round: 2}}
        }
        {%- if forloop.last == false -%},{% endif %}
        {%- endfor %}
    ]
}

Sum tax lines

You can notice that each line item has a list of tax_lines. Use the following code snippet to calculate total tax and net price per line item:

<items>
	{%- for item in order.line_items %}
	<item>
		{%- assign tax_amount = 0.0 -%}
		{%- for tax_line in item.tax_lines -%}
			{%- assign tax_amount = tax_amount | plus: tax_line.price -%}
		{%- endfor %}
		{%- assign total_price = item.price | times: item.quantity %}
		{%- assign net_total_price = total_price | minus: tax_amount %}
    <total_price>{{ total_price }}</total_price>
		<net_price>{{ net_total_price }}<net_price>
	</item>
	{%- endfor %}
</items>

Metafields

Metafields contain additional information associated with an order, customer, product or variant. You can configure metafields in your store settings. They can be also created and filled in by other apps. To get value of a specific metafield, you need to provide its namespace and key. For example:

Customer metafield
{{ order.customer.erp.id }}
Order metafield
{{ order.metafields.custom.pack_slip_id }}
Product metafield
{%- for item in order.line_items %}
    <pack_qty>{{ item.product.metafields.inventory.pack_quantity }}</pack_qty>
{%- endfor %}
Variant metafield
{%- for item in order.line_items %}
    <paperType>{{ item.variant.metafields.print.paper_type }}</paperType>
{%- endfor %}

Shipping Address

The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require shipping. It has the following properties:

  • order.shipping_address.address1: The street address of the billing address.

  • order.shipping_address.address2: An optional additional field for the street address of the billing address.

  • order.shipping_address.city: The city, town, or village of the billing address.

  • order.shipping_address.company: The company of the person associated with the billing address.

  • order.shipping_address.country: The name of the country of the billing address.

  • order.shipping_address.country_code: The two-letter code (ISO 3166-1 format) for the country of the billing address.

  • order.shipping_address.first_name: The first name of the person associated with the payment method.

  • order.shipping_address.last_name: The last name of the person associated with the payment method.

  • order.shipping_address.latitude: The latitude of the billing address.

  • order.shipping_address.longitude: The longitude of the billing address.

  • order.shipping_address.name: The full name of the person associated with the payment method.

  • order.shipping_address.phone: The phone number at the billing address.

  • order.shipping_address.province: The name of the region (province, state, prefecture, …) of the billing address.

  • order.shipping_address.province_code: The two-letter abbreviation of the region of the billing address.

  • order.shipping_address.zip: The postal code (zip, postcode, Eircode, …) of the billing address.

Shipping Cost

  • order.total_shipping_price_set: The total shipping price of the order, excluding discounts and returns, in shop and presentment currencies. If order.taxes_included is set to true, then total_shipping_price_set includes taxes.

"total_shipping_price_set": {
  "shop_money": {
    "amount": "30.00",
    "currency_code": "USD"
  },
  "presentment_money": {
    "amount": "0.00",
    "currency_code": "USD"
  }
}

Shipping Method

  • order.shipping_lines: An array of objects, each of which details a shipping method used. Each object has the following properties:

    • code: A reference to the shipping method.

    • discounted_price: The price of the shipping method after line-level discounts have been applied. Doesn't reflect cart-level or order-level discounts.

    • discounted_price_set: The price of the shipping method in both shop and presentment currencies after line-level discounts have been applied.

    • price: The price of this shipping method in the shop currency. Can't be negative.

    • price_set: The price of the shipping method in shop and presentment currencies.

    • source: The source of the shipping method.

    • title: The title of the shipping method.

    • tax_lines: A list of tax line objects, each of which details a tax applicable to this shipping line.

    • carrier_identifier: A reference to the carrier service that provided the rate. Present when the rate was computed by a third-party carrier service.

    • requested_fulfillment_service_id: A reference to the fulfillment service that is being requested for the shipping method. Present if the shipping method requires processing by a third party fulfillment service; null otherwise.

"shipping_lines": [
  {
    "code": "INT.TP",
    "price": "4.00",
    "price_set": {
      "shop_money": {
        "amount": "4.00",
        "currency_code": "USD"
      },
      "presentment_money": {
        "amount": "3.17",
        "currency_code": "EUR"
      }
    },
    "discounted_price": "4.00",
    "discounted_price_set": {
      "shop_money": {
        "amount": "4.00",
        "currency_code": "USD"
      },
      "presentment_money": {
        "amount": "3.17",
        "currency_code": "EUR"
      }
    },
    "source": "canada_post",
    "title": "Small Packet International Air",
    "tax_lines": [],
    "carrier_identifier": "third_party_carrier_identifier",
    "requested_fulfillment_service_id": "third_party_fulfillment_service_id"
  }
]

If you are sure that your orders won't be divided into multiple shipments, then you can simplify getting the shipping method to {{ order.shipping_lines[0].title }} .

You can use case/when instructions to map shipping method names to supplier-accepted codes.

<DeliveryCode>
{%- case order.shipping_lines[0].title -%}
{%- when "UPS Next Day Air" -%}
  ZZ_US1D
{%- when "UPS 2 Day Air" -%}
  ZZ_US2D
{%- when "UPS Ground" -%}
  ZZ_USGN
{%- when "UPS Surepost" -%}
  ZZ_USSL
{%- endcase -%}
</DeliveryCode>

Status

Shopify includes 2 fields describing order status:

  • order.financial_status The status of payments associated with the order. Can only be set when the order is created. Possible values:

    • pending: The payments are pending. Payment might fail in this state. Check again to confirm whether the payments have been paid successfully.

    • authorized: The payments have been authorized.

    • partially_paid: The order have been partially paid.

    • paid: The payments have been paid.

    • partially_refunded: The payments have been partially refunded.

    • refunded: The payments have been refunded.

    • voided: The payments have been voided.

  • order.fulfillment_status The order's status in terms of fulfilled line items. Possible values:

    • fulfilled: Every line item in the order has been fulfilled.

    • null: None of the line items in the order have been fulfilled.

    • partial: At least one line item in the order has been fulfilled.

    • restocked: Every line item in the order has been restocked and the order canceled.

Totals

If you added an item filter, and selected the checkbox to exclude items not matching the filter, then you may need to calculate totals based on the filtered line items. For example, check out the code snippet to calculate total weight.

  • order.total_discounts The total discounts applied to the price of the order in the shop currency.

  • order.total_discounts_set The total discounts applied to the price of the order in shop and presentment currencies.

    • order.total_discounts_set.shop_money.amount

    • order.total_discounts_set.shop_money.currency

    • order.total_discounts_set.presentment_money.amount

    • order.total_discounts_set.presentment_money.currency

  • order.total_line_items_price The sum of all line item prices in the shop currency.

  • order.total_line_items_price_set The total of all line item prices in shop and presentment currencies.

    • order.total_line_items_price_set.shop_money.amount

    • order.total_line_items_price_set.shop_money.currency

    • order.total_line_items_price_set.presentment_money.amount

    • order.total_line_items_price_set.presentment_money.currency

  • order.total_outstanding The total outstanding amount of the order in the shop currency.

  • order.total_price The sum of all line item prices, discounts, shipping, taxes, and tips in the shop currency.

  • order.total_price_setThe total price of the order in shop and presentment currencies.

    • order.total_price_set.shop_money.amount

    • order.total_price_set.shop_money.currency

    • order.total_price_set.presentment_money.amount

    • order.total_price_set.presentment_money.currency

  • order.total_shipping_price_set The total shipping price of the order, excluding discounts and returns, in shop and presentment currencies. If taxes_included is set to true, then order.total_shipping_price_set includes taxes.

  • order.total_tax The sum of all the taxes applied to the order in the shop currency

  • order.total_tax_set The total tax applied to the order in shop and presentment currencies.

    • order.total_tax_set.shop_money.amount

    • order.total_tax_set.shop_money.currency

    • order.total_tax_set.presentment_money.amount

    • order.total_tax_set.presentment_money.currency

  • order.total_tip_received The sum of all the tips in the order in the shop currency.

  • order.total_weight The sum of all line item weights in grams.

Transactions

order.transactions contains the list of transactions. Each transaction has the following properties:

Property

Description

amount

The amount of money included in the transaction. If you don't provide a value for amount, then it defaults to the total cost of the order (even if a previous transaction has been made towards it).

authorization

The authorization code associated with the transaction.

created_at

The date and time (ISO 8601 format) when the transaction was created.

currency

The three-letter code (ISO 4217 format) for the currency used for the payment.

device_id

The ID for the device.

error_code

A standardized error code, independent of the payment provider. Valid values:

  • incorrect_number

  • invalid_number

  • invalid_expiry_date

  • invalid_cvc

  • expired_card

  • incorrect_cvc

  • incorrect_zip

  • incorrect_address

  • card_declined

  • processing_error

  • call_issuer

  • pick_up_card

gateway

The name of the gateway the transaction was issued through. A list of gateways can be found on Shopify's payment gateways page.

id

The ID for the transaction.

kind

The transaction's type. Valid values:

  • authorization: Money that the customer has agreed to pay. The authorization period can be between 7 and 30 days (depending on your payment service) while a store waits for a payment to be captured.

  • capture: A transfer of money that was reserved during the authorization of a shop.

  • sale: The authorization and capture of a payment performed in one single step.

  • void: The cancellation of a pending authorization or capture.

  • refund: The partial or full return of captured money to the customer.

location_id

The ID of the physical location where the transaction was processed.

message

A string generated by the payment provider with additional information about why the transaction succeeded or failed.

order_id

The ID for the order that the transaction is associated with.

payment_details

Information about the credit card used for this transaction. It has the following properties:

  • avs_result_code: The response code from the address verification system. The code is a single letter; see this chart for the codes and their definitions.

  • credit_card_bin: The issuer identification number (IIN), formerly known as bank identification number (BIN) of the customer's credit card. This is made up of the first few digits of the credit card number.

  • credit_card_company: The name of the company that issued the customer's credit card.

  • credit_card_number: The customer's credit card number, with most of the leading digits redacted.

  • cvv_result_code: The response code from the credit card company indicating whether the customer entered the card security code, or card verification value, correctly. The code is a single letter or empty string; see this chart for the codes and their definitions.

parent_id

The ID of an associated transaction.

  • For capture transactions, the parent needs to be an authorization transaction.

  • For void transactions, the parent needs to be an authorization transaction.

  • For refund transactions, the parent needs to be a capture or sale transaction.

processed_at

The date and time (ISO 8601 format) when a transaction was processed. This value is the date that's used in the analytic reports. By default, it matches the created_at value. If you're importing transactions from an app or another platform, then you can set processed_at to a date and time in the past to match when the original transaction was processed.

receipt

A transaction receipt attached to the transaction by the gateway. The value of this field depends on which gateway the shop is using.

For example, if gateway is gift_card, then receipt contains gift_card_id and gift_card_last_characters.

source_name

The origin of the transaction. This is set by Shopify and can't be overridden. Example values: web, pos, iphone, and android.

status

The status of the transaction. Valid values: pending, failure, success, and error.

test

Whether the transaction is a test transaction.

user_id

The ID for the user who was logged into the Shopify POS device when the order was processed, if applicable.

The best way to output all transactions is to use a for loop.

{
    "transactions": [
        {%- for transaction in order.transactions %} 
        {
            "amount": {{ transaction.amount | json }},
            "currency": {{ transaction.currency | json }},
            "gateway": {{ transaction.gateway | json }},
            "status": {{ transaction.status| json }}
        }
        {%- if forloop.last == false -%},{% endif %}
        {%- endfor %}
    ]
}

To get credit card details (company, masked number):

{%- assign capture_payment_details = order.transactions | where: "kind","capture" | where: "status", "success" | map: "payment_details" | first %}
{%- assign sale_payment_details = order.transactions | where: "kind","sale" | where: "status", "success" | map: "payment_details" | first %}
{%- assign payment_details = capture_payment_details | default: sale_payment_details %}
{%- if payment_details %}
<creditCard>
    <company>{{ payment_details.credit_card_company }}</company>
    <number>{{ payment_details.credit_card_number }}</number>
</creditCard>
{%- endif %}

Last updated