Liquid variables

Exporteo uses the Liquid template language to transform orders to a desired output format.

The base variable is the order object. It 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

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

Discount codes

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

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

Currently it's possible to apply only one discount code in Shopify orders. 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 }}

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.

  • 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.tags: The list of product tags.

  • properties: An array of custom information for the item that has been added to the cart. Often used to provide product customization options.

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

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

JSON
XML
JSON
{
"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 %}
]
}
XML
<items>
{%- for item in order.line_items %}
<item>
<product_id>{{item.product_id}}</product_id>
<variant_id>{{item.variant_id}}</variant_id>
<sku>{{item.sku}}</sku>
<title>{{item.title}}</title>
<price>{{item.price}}</price>
<quantity>{{item.quantity}}</quantity>
<total_price>{{item.price | times: item.quantity | money }}</total_price>
</item>
{%- endfor %}
</items>

Skip a specific line item

If you need to skip a specific line item then you can use an if statement. Let's say you want to exclude a line item named "Donation". You can use the following expression:

{%- if line_item.name != "Donation" -%} ... item details ... {%- endif -%}

For JSON format, you'll need an extra check to control when to output a comma between subsequent elements.

CSV
JSON
XML
CSV
SKU,Title,Price,Quantity
{%- for line_item in order.line_items %}
{%- if line_item.title != "Donation" %}
{{ line_item.sku -}},
{{- line_item.title -}},
{{- line_item.price -}},
{{- line_item.quantity -}}
{%- endif -%}
{%- endfor %}
JSON
{
"line_items": [
{%- for item in order.line_items %}
{%- if item.title != "Description" %}
{
"sku": {{ item.sku | json }},
"title": {{ item.title | json }},
"price": {{ item.price | json }},
"quantity": {{ item.quantity | json }}
}
{%- assign next_item = order.line_items[forloop.index] -%}
{%- if forloop.last == false and next_item.title != "Description" -%}
,
{%- endif %}
{%- endif %}
{%- endfor %}
]
}
XML
<items>
{%- for item in order.line_items %}
{%- if item.title != "Description" %}
<item>
<sku>{{item.sku}}</sku>
<title>{{item.title}}</title>
<price>{{item.price}}</price>
<quantity>{{item.quantity}}</quantity>
</item>
{%- endif %}
{%- endfor %}
</items>

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>

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

  • 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

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

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.

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.

JSON
XML
JSON
{
"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 %}
]
}
XML
<transactions>
{%- for transaction in order.transactions %}
<transaction>
<amount>{{ transaction.amount }}</amount>
<currency>{{ transaction.currency }}</variant_id>
<gateway>{{ transaction.gateway }}</gateway>
<kind>{{ transaction.kind }}</kind>
<status>{{ transaction.status }}</status>
</transaction>
{%- endfor %}
</transactions>