# 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](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 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.

{% tabs %}
{% tab title="Fixed Amount Discount" %}
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"
    }
]
```

{% endtab %}

{% tab title="Percentage Discount" %}
A discount application of %10 off with code WELCOME.

```
[
    {
        "allocation_method": "across",
        "code": "WELCOME"
        "target_selection": "all",
        "target_type": "line_item",
        "type": "discount_code",
        "value": "10.0",
        "value_type": "percentage"
    }
]
```

{% endtab %}

{% tab title="Two Manual Discounts" %}
Two manual discounts stacked on a draft order:

* 25% off applied to a specific item
* 10% off applied to the entire order

```
[
    {
        "allocation_method": "across",
        "description": "Astronaut discount",
        "value": "25.0",
        "value_type": "percentage",
        "target_selection": "explicit",
        "target_type": "line_item",
        "title": "Astronaut discount",
        "type": "manual"
    },
    {
        "allocation_method": "across",
        "description": "First trip to Mars",
        "value": "10.0",
        "value_type": "percentage",
        "target_selection": "all",
        "target_type": "line_item",
        "title": "First trip to Mars",
        "type": "manual"
    }
]
```

{% endtab %}
{% endtabs %}

`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.note_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:

* **current\_quantity:** The line item's quantity, minus the removed quantity.
* **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](https://shopify.dev/docs/admin-api/rest/reference/orders/%E2%80%9C/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentorder%E2%80%9D) to determine the location an item will be sourced from.
  * `country_code`: The two-letter code ([ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 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. Doesn't reflect edited or removed items.
* **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.

{% tabs %}
{% tab title="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 %}
    ]
}
```

{% endtab %}

{% tab title="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>
```

{% endtab %}
{% endtabs %}

#### 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:

<pre data-title="Customer metafield"><code><strong>{{ order.customer.erp.id }}
</strong></code></pre>

{% code title="Order metafield" %}

```
{{ order.metafields.custom.pack_slip_id }}
```

{% endcode %}

<pre data-title="Product metafield"><code>

<strong>    &#x3C;pack_qty>{{ item.product.metafields.inventory.pack_quantity }}&#x3C;/pack_qty>
</strong>

</code></pre>

{% code title="Variant metafield" %}

```
{%- for item in order.line_items %}
    <paperType>{{ item.variant.metafields.print.paper_type }}</paperType>
{%- endfor %}
```

{% endcode %}

### 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](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 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

{% hint style="info" %}
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](https://help.exporteo.solvenium.com/useful-code-snippets#total-weight).
{% endhint %}

* `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_set`The 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](https://en.wikipedia.org/wiki/ISO_8601) format) when the transaction was created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| currency         | The three-letter code ([ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format) for the currency used for the payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| device\_id       | The ID for the device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| error\_code      | <p>A standardized error code, independent of the payment provider. Valid values:</p><ul><li><strong>incorrect\_number</strong></li><li><strong>invalid\_number</strong></li><li><strong>invalid\_expiry\_date</strong></li><li><strong>invalid\_cvc</strong></li><li><strong>expired\_card</strong></li><li><strong>incorrect\_cvc</strong></li><li><strong>incorrect\_zip</strong></li><li><strong>incorrect\_address</strong></li><li><strong>card\_declined</strong></li><li><strong>processing\_error</strong></li><li><strong>call\_issuer</strong></li><li><strong>pick\_up\_card</strong></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| gateway          | The name of the gateway the transaction was issued through. A list of gateways can be found on Shopify's [payment gateways page](https://www.shopify.com/payment-gateways).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| id               | The ID for the transaction.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| kind             | <p>The transaction's type. Valid values:</p><ul><li><strong>authorization</strong>: 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.</li><li><strong>capture</strong>: A transfer of money that was reserved during the authorization of a shop.</li><li><strong>sale</strong>: The authorization and capture of a payment performed in one single step.</li><li><strong>void</strong>: The cancellation of a pending authorization or capture.</li><li><strong>refund</strong>: The partial or full return of captured money to the customer.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| 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 | <p>Information about the credit card used for this transaction. It has the following properties:</p><ul><li><strong>avs\_result\_code</strong>: The response code from the <a href="https://en.wikipedia.org/wiki/Address_Verification_System">address verification system</a>. The code is a single letter; see <a href="http://www.emsecommerce.net/avs_cvv2_response_codes.htm">this chart</a> for the codes and their definitions.</li><li><strong>credit\_card\_bin</strong>: The <a href="https://en.wikipedia.org/wiki/ISO/IEC_7812">issuer identification number</a> (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.</li><li><strong>credit\_card\_company</strong>: The name of the company that issued the customer's credit card.</li><li><strong>credit\_card\_number</strong>: The customer's credit card number, with most of the leading digits redacted.</li><li><strong>cvv\_result\_code</strong>: The response code from the credit card company indicating whether the customer entered the <a href="https://en.wikipedia.org/wiki/Card_Security_Code">card security code</a>, or card verification value, correctly. The code is a single letter or empty string; see <a href="http://www.emsecommerce.net/avs_cvv2_response_codes.htm">this chart</a> for the codes and their definitions.</li></ul> |
| parent\_id       | <p>The ID of an associated transaction.</p><ul><li>For <code>capture</code> transactions, the parent needs to be an <code>authorization</code> transaction.</li><li>For <code>void</code> transactions, the parent needs to be an <code>authorization</code> transaction.</li><li>For <code>refund</code> transactions, the parent needs to be a <code>capture</code> or <code>sale</code> transaction.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| processed\_at    | The date and time ([ISO 8601](https://en.wikipedia.org/wiki/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          | <p>A transaction receipt attached to the transaction by the gateway. The value of this field depends on which gateway the shop is using.</p><p>For example, if gateway is <code>gift\_card</code>, then receipt contains <code>gift\_card\_id</code> and <code>gift\_card\_last\_characters</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 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.

{% tabs %}
{% tab title="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 %}
    ]
}
```

{% endtab %}

{% tab title="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>
```

{% endtab %}
{% endtabs %}

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

```markup
{%- 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 %}
```
