# Email

Exporteo is able to send order data by email. You can use this destination channel to integrate with external systems, or to send invoices to your customers.

<figure><img src="/files/Kl8cvh4AVgz5V5WilHo6" alt="Configuration screen showing email destination settings in Exporteo, including recipient fields and message options"><figcaption><p>Exporteo email destination settings</p></figcaption></figure>

### **From**

By default, the From address is `<store>@exporteo.solvenium.com`, where `<store>` is your Shopify account handle. You can update the From address by configuring the SMTP settings in the Provider section.

### **Provider**

By default, the provider is set to Exporteo (AWS SES). You can switch it to SMTP, which allows you to use a custom From address after configuring the required fields: Host, Port, User, and Password. Click the gear icon next to the From field.

<figure><img src="/files/nAcu6voLe7ThD4Hpzljw" alt="Configuration screen showing SMTP settings used to set a custom From email address in Exporteo"><figcaption><p>SMTP settings for configuring a custom From email address in Exporteo</p></figcaption></figure>

### To

The **To** address can be either a fixed email address or dynamically generated from a Liquid code.

For example, you can send the email to the customer who placed the order by using the following Liquid expression `{{ order.email }}`.

Separate multiple addresses with commas.

<figure><img src="/files/D4wfGtEh5lCALS2azRQn" alt=""><figcaption></figcaption></figure>

### CC

Enter one or more email addresses that should receive a copy of the message. Separate multiple addresses with commas.

### Reply To

Optionally, you can set a **Reply To** address. This is useful when sending emails to customers. They can reply to you, instead of Exporteo's source address.

### Subject

The **Subject** field accepts a Liquid code. The main variable is `order` in automations that process a single order or `orders` in the bulk mode.

Useful Liquid expressions for the Subject field:

* `{{ order.name }}` - order number with prefix, e.g. #1023
* `{{ order.order_number }}` - order number starting from 1000, e.g. 1023
* `{{ order.created_at | date: "%Y-%m-%d" }}` - order creation date formatted as year-month-day, e.g. 2023-04-05

### Body

Enter the content of the email message. This field supports plain text and Liquid. It can be used to include additional information or instructions for the recipient.

### Output as

You can send the generated output as email content or as an attachment.

Selecting the *Content* option changes the list of available formats to CSV, HTML, JSON, and XML.

PDF and XLSX can only be sent as attachments.


# HTTP

The HTTP channel is useful for pushing your Shopify orders to a REST API, a GraphQL interface, or a SOAP web service.

### URL

The first step is to specify the target URL.

<figure><img src="/files/PAD5sqzqvcSiyu8N5d0d" alt="HTTP target URL set to https://api.posterflow.de/api/"><figcaption></figcaption></figure>

You can include [Liquid variables](/liquid/liquid-variables) in the URL. For example, to pass the order number in the path, set the URL to:

```
https://api.example.com/orders/{{order.order_number}}
```

A special Liquid variable for the URL field is the `{{output}}` variable which stores the entire content generated from the output template. It can be useful in rare cases when a web service accepts data only through the query parameters.

```
https://ecommerce.gardenimpressions.nl/webservices/garden-mkpprod/PutOrder?XMLTEXT={{output | url_encode}}
```

### Method

You can select one of the following HTTP methods: GET, POST, or PUT.

In most cases, the desired method is POST.

For POST and PUT methods, the generated output is passed in the request payload body.

### Headers

HTTP headers are pieces of information that are sent along with the main payload. An HTTP header consist of a key (a fixed name), and value. One of the most popular headers is `Content-Type`. The `Content-Type` header is automatically added by Exporteo, and changes according to the selected output format.

<figure><img src="/files/X2ihD4nV3dLVyDd9mryx" alt="Content-Type header set to text/csv"><figcaption></figcaption></figure>

| Output Format | Content-Type     |
| ------------- | ---------------- |
| CSV           | text/csv         |
| JSON          | application/json |
| XML           | application/xml  |

However, you may need to adjust the `Content-Type` header for the XML output formats, as some web services require `text/xml` instead of `application/xml`.

### Authentication

Exporteo supports four authentication methods:

#### No Auth <a href="#no-auth" id="no-auth"></a>

No authentication is sent with the request. Use this for public endpoints or when authentication is handled in another way — for example, through a custom header or an API key passed directly in the URL as a query parameter (e.g. `https://api.example.com/orders?api_key=YOUR_KEY`).

#### Basic Auth <a href="#basic-auth" id="basic-auth"></a>

Standard HTTP basic authentication. Enter a **username** and **password**, and Exporteo will send them as an `Authorization: Basic ...` header with each request.

#### Bearer Token <a href="#bearer-token" id="bearer-token"></a>

Token-based authentication. Enter the **token** value, and Exporteo will include it as an `Authorization: Bearer ...` header.

#### Request <a href="#request" id="request"></a>

Use this when the API requires a separate authentication step before the main request — for example, when you need to call a login endpoint first to obtain a temporary token.

Configure the authentication request:

1. Choose the **Method** (GET or POST).
2. Enter the **Auth URL** — the endpoint that returns the authentication token.
3. For POST requests, select the **Content Type** and enter the **Body** (e.g. JSON with your API credentials).

After saving, Exporteo will first call the Auth URL, then use the response in the main request. Reference the authentication response in the main request URL or headers using the `{{ auth }}` variable. If the authentication response is JSON, you can reference specific fields — for example, `{{ auth.token }}` or `{{ auth.access_token }}`.

**OAuth2 (Request method)**

OAuth 2.0 is a standard for delegated authorization that allows applications to obtain limited access to an API on behalf of a user or system.

In Exporteo, OAuth2 is handled as a special case of the **Request** authentication method, because it requires an initial request to retrieve an access token before calling the main endpoint.

In a typical setup:

* A **POST** request is sent to the token endpoint (Auth URL)
* The request includes credentials (e.g. `client_id`, `client_secret`)
* The response contains an **access token**

This token is then used in the main request, typically in the Authorization header.

**Example (Client Credentials flow)**

Auth request:

```
POST https://api.example.com/oauth2/token
Content-Type: application/x-www-form-urlencoded

Body:
grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET
```

Response:

```
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

Authorization header used in the main request:

```
Authorization: Bearer {{ auth.access_token }}
```

Setup:

<figure><img src="/files/OlW3R8psLgbnmEhhsKzB" alt="Configuration screen showing OAuth2 authentication settings in Exporteo"><figcaption><p>OAuth2 authentication setup in Exporteo</p></figcaption></figure>

Depending on the specific API, this flow may vary slightly (e.g. different parameters, request format, or authentication method). Always refer to the API documentation for the exact implementation details.


# FTP

The FTP(S) channel allows you to upload order data files directly to an FTP server. This is useful for integrating with suppliers, warehouses, or other systems that receive data via FTP file transfers.

<figure><img src="/files/20Ny5WUrr6AGaq1tkYjj" alt=""><figcaption><p>Exporteo FTP(S) destination settings</p></figcaption></figure>

## Protocol

Select the protocol for the FTP connection:

<table><thead><tr><th width="120.234375">Protocol</th><th>Description</th><th>Default Port</th></tr></thead><tbody><tr><td>ftp://</td><td>Standard FTP (unencrypted)</td><td>21</td></tr><tr><td>ftps://</td><td>FTP over TLS/SSL (encrypted)</td><td>990</td></tr><tr><td>sftp://</td><td>SSH File Transfer Protocol</td><td>22</td></tr></tbody></table>

{% hint style="warning" %}
Standard FTP transmits credentials and data in plain text. For security, use FTPS or SFTP whenever possible.
{% endhint %}

### Accept self-signed certificate

When using **ftps\://**, an additional checkbox appears: **Accept self-signed certificate**. Enable this option if your FTP server uses a self-signed SSL certificate instead of a certificate issued by a trusted Certificate Authority.

## Host

Enter the hostname or IP address of the FTP server, for example `ftp.example.com` or `11.22.33.44`.

Do not include the protocol prefix (ftp\://, ftps\://, sftp\://) in this field—select the protocol from the dropdown instead.

## Port

The port number for the FTP connection. Default ports are automatically set based on the selected protocol:

* **FTP**: 21
* **FTPS**: 990
* **SFTP**: 22

Change the port if your server uses a non-standard port configuration.

{% hint style="info" %}
Some FTPS servers use explicit TLS on port 21 instead of implicit TLS on port 990. If you have trouble connecting with port 990, try using port 21.
{% endhint %}

## Username

The username for FTP authentication.

## Password

The password for FTP authentication.

{% hint style="info" %}
Your FTP password is stored securely and encrypted. It will not be visible after saving.
{% endhint %}

## Upload folder

The directory path on the FTP server where files will be uploaded. Leave empty to upload to the root directory or the user's home directory.

Examples:

* `/orders` - upload to the "orders" folder in the root directory
* `/incoming/shopify` - upload to a nested folder relative to the home directory
* Leave empty - upload to the root directory

{% hint style="info" %}
The folder path syntax may vary depending on your FTP server configuration. If you're unsure, consult your FTP server administrator or test with different path formats.
{% endhint %}

## File name

The name of the file to be created on the FTP server. You can use [Liquid variables](/liquid/liquid-variables) to generate dynamic file names.

Examples:

* `order_{{order.order_number}}.xml` - creates files like `order_1023.xml`
* `{{order.order_number}}_{{order.created_at | date: "%Y%m%d"}}.json` - creates files like `1023_20240506.json`
* `export_{{order.id}}.csv` - creates files like `export_5678901234.csv`

{% hint style="warning" %}
Ensure your file names are unique to prevent overwriting existing files. Including the order number or order ID in the file name is recommended.
{% endhint %}

## Connect

Click the **Connect** button to test your FTP connection before saving. Exporteo will attempt to:

1. Establish a connection to the FTP server
2. Authenticate with the provided credentials
3. Verify access to the upload folder (if specified)

If the connection is successful, the settings will be confirmed. If it fails, an error message will help you diagnose the issue.

### Common connection issues

| Error                 | Possible cause          | Solution                                    |
| --------------------- | ----------------------- | ------------------------------------------- |
| Connection refused    | Wrong host or port      | Verify the hostname and port number         |
| Authentication failed | Wrong credentials       | Check username and password                 |
| Certificate error     | Self-signed certificate | Enable "Accept self-signed certificate"     |
| Timeout               | Firewall blocking       | Check firewall rules allow FTP traffic      |
| Directory not found   | Wrong upload folder     | Verify the folder path exists on the server |


# Feed URL

The Feed URL channel allows you to access exported order data through a dedicated URL. This URL always returns the most recent file generated by your automation, making it easy for external systems to retrieve up-to-date data.

This option is available only in the **Scheduled / Bulk** processing mode.

<figure><img src="/files/otO0Gxbb2K5fyaxnprWd" alt="Screenshot showing the Exporteo Feed URL destination channel, where a fixed URL is generated to access the most recent exported order file automatically."><figcaption><p>Feed URL destination channel in Exporteo, providing a fixed link to the latest exported order data</p></figcaption></figure>

Access is secured using Basic Authentication with a username and password. Authentication can also be disabled if required.

<figure><img src="/files/wSsMvHzArHO1dy5Pt0UA" alt="Screenshot showing the Exporteo Feed URL settings with an option to disable Basic Authentication for accessing exported order data."><figcaption><p>Option to disable authentication for the Feed URL channel in Exporteo.</p></figcaption></figure>


# 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](/liquid/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 %}
```


# Liquid filters

Filters are simple methods that modify the output of numbers, strings, variables and objects. They are placed within an output tag `{{` `}}` and are denoted by a pipe character `|`.

{% code title="Input" %}

```
<!-- item.title = "Invisible Watch" -->
{{ item.title | upcase }}
```

{% endcode %}

{% code title="Output" %}

```
INVISIBLE WATCH
```

{% endcode %}

In the example above, `item` is the object, `title` is its attribute, and `upcase` is the filter being applied.

Some filters require a parameter to be passed.

{% code title="Input" %}

```
{{ item.title | remove: "Invisible" }}
```

{% endcode %}

{% code title="Output" %}

```
Watch
```

{% endcode %}

Multiple filters can be used on one output. They are applied from left to right.

{% code title="Input" %}

```
<!-- item.title = "Invisible Watch" -->
{{ item.title | upcase | remove: "INVISIBLE"  }}
```

{% endcode %}

{% code title="Output" %}

```
WATCH
```

{% endcode %}

## Array filters

Array filters change the output of arrays. Array is a synonym to list. For example, `order.line_items` is an array of line items or `order.transactions` is an array of transactions.

### join <a href="#join" id="join"></a>

Joins the elements of an array with the character passed as the parameter. The result is a single string.

{% code title="Input" %}

```
{{ product.tags | join: ', ' }}
```

{% endcode %}

{% code title="Output" %}

```
tag1, tag2, tag3
```

{% endcode %}

### first <a href="#first" id="first"></a>

Returns the first element of an array.

{% code title="Input" %}

```
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
{{ product.tags | first }}
```

{% endcode %}

{% code title="Output" %}

```
sale
```

{% endcode %}

You can use `first` with dot notation when you need to use the filter inside a tag.

```
{% if product.tags.first == "sale" %}
  This product is on sale!
{% endif %}
```

### last <a href="#last" id="last"></a>

Returns the last element of an array.

{% code title="Input" %}

```
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
{{ product.tags | last }}
```

{% endcode %}

{% code title="Output" %}

```
awesome
```

{% endcode %}

You can use `last` with dot notation when you need to use the filter inside a tag.

```
{% if product.tags.last == "sale"%}
  This product is on sale!
{% endif %}
```

Using `last` on a string returns the last character in the string.

{% code title="Input" %}

```
<!-- product.title = "Awesome Shoes" -->
{{ product.title | last }}
```

{% endcode %}

{% code title="Output" %}

```
s
```

{% endcode %}

### concat <a href="#concat" id="concat"></a>

Concatenates (combines) an array with another array. The resulting array contains all the elements of the original arrays. `concat` will not remove duplicate entries from the concatenated array unless you also use the [`uniq`](#uniq) filter.

{% code title="Input" %}

```
{% assign fruits = "apples, oranges, peaches, tomatoes" | split: ", " %}
{% assign vegetables = "broccoli, carrots, lettuce, tomatoes" | split: ", " %}

{% assign plants = fruits | concat: vegetables %}

{{ plants | join: ", " }}
```

{% endcode %}

{% code title="Output" %}

```
apples, oranges, peaches, tomatoes, broccoli, carrots, lettuce, tomatoes
```

{% endcode %}

You can string together multiple `concat` filters to combine more than two arrays:

{% code title="Input" %}

```
{% assign fruits = "apples, oranges, peaches" | split: ", " %}
{% assign vegetables = "broccoli, carrots, lettuce" | split: ", " %}
{% assign animals = "dogs, cats, birds" | split: ", " %}

{% assign things = fruits | concat: vegetables | concat: animals %}

{{ things | join: ", " }}
```

{% endcode %}

{% code title="Output" %}

```
apples, oranges, peaches, broccoli, carrots, lettuce, dogs, cats, birds
```

{% endcode %}

### index <a href="#index" id="index"></a>

Returns the item at the specified index location in an array. Note that array numbering starts from zero, so the first item in an array is referenced with `[0]`.

{% code title="Input" %}

```
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
{{ product.tags[2] }}
```

{% endcode %}

{% code title="Output" %}

```
womens
```

{% endcode %}

### map <a href="#map" id="map"></a>

Accepts an array element's attribute as a parameter and creates an array out of each array element's value.

{% code title="Input" %}

```
<!-- collection.title = "Spring", "Summer", "Fall", "Winter" -->
{% assign collection_titles = collections | map: 'title' %}
{{ collection_titles }}
```

{% endcode %}

{% code title="Output" %}

```
SpringSummerFallWinter
```

{% endcode %}

### flat\_map ⭐ <a href="#flat_map" id="flat_map"></a>

Creates a flattened array of values taken from the specified attribute of each element of the input array.

{% code title="Input" %}

```
<!-- 
    order = {
        line_items: [{
            discount_allocations: [{
                amount: 1.23
            }, {
                amount: 2.34
            }]
        }, {
            discount_allocations: [{
                amount: 3.45
            }]
        }]
    }
-->
{{ order.line_items | flat_map: "discount_allocations" | json }}
```

{% endcode %}

{% code title="Output" %}

```
[{"amount":1.23},{"amount":2.34},{"amount":3.45}]
```

{% endcode %}

### group\_by ⭐ <a href="#group_by" id="group_by"></a>

Groups elements of the same property value. Creates an object where keys are the specified property value, and values are arrays of elements with the same property value.

{% code title="Input" %}

```
<!--
    order = {
        line_items: [{
            price: 1.23,
            vendor: "A"
        }, {
            price: 2.34, 
            vendor: "B"
        }, {
            price: 3.45, 
            vendor: "A"
        }]
    }
-->
{{ order.line_items | group_by: "vendor" | json }
```

{% endcode %}

{% code title="Output" %}

```
{"A":[{"price":1.23,"vendor":"A"},{"price":3.45,"vendor":"A"}],"B":[{"price":2.34,"vendor":"B"}]}
```

{% endcode %}

### map\_values ⭐ <a href="#map_values" id="map_values"></a>

Transforms an object by running each of the object's property value by a given filter. First parameter of `map_values` is the filter name. The filter receives the object values one by one as its first parameter. All remaining parameters provided to `map_values` are passed down to the given filter.

{% code title="Input" %}

```
<!--
    dimensions = { depth: 3, height: 5, width: 7 } 
-->

{% assign doubled = dimensions | map_values: "times", 2 %}
{{ doubled.depth }}
{{ doubled.height }}
{{ doubled.width }}
```

{% endcode %}

{% code title="Output" %}

```
6
10
14
```

{% endcode %}

### reverse <a href="#reverse" id="reverse"></a>

Reverses the order of the items in an array.

{% code title="Input" %}

```
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}

{{ my_array | reverse | join: ", " }}
```

{% endcode %}

{% code title="Output" %}

```
plums, peaches, oranges, apples
```

{% endcode %}

### size <a href="#size" id="size"></a>

Returns the size of a string (the number of characters) or an array (the number of elements).

{% code title="Input" %}

```
{{ 'The quick brown fox jumps over a lazy dog.' | size }}
```

{% endcode %}

{% code title="Output" %}

```
42
```

{% endcode %}

You can use `size` with dot notation when you need to use the filter inside a tag.

```
{% if collections.frontpage.products.size > 10 %}
  There are more than 10 products in this collection!
{% endif %}
```

### sort <a href="#sort" id="sort"></a>

Sorts the elements of an array by a given attribute of an element in the array.

```
{% assign products = collection.products | sort: 'price' %}
{% for product in products %}
  <h4>{{ product.title }}</h4>
{% endfor %}
```

The order of the sorted array is case-sensitive.

{% code title="Input" %}

```
<!-- products = "a", "b", "A", "B" -->
{% assign products = collection.products | sort: 'title' %}
{% for product in products %}
   {{ product.title }}
{% endfor %}
```

{% endcode %}

{% code title="Output" %}

```
A B a b
```

{% endcode %}

### where <a href="#where" id="where"></a>

Creates an array including only the objects with a given property value, or any [truthy](https://shopify.dev/docs/themes/liquid/reference/basics/true-and-false#truthy) value by default.

{% code title="Input" %}

```
All products:
{% for product in collection.products %}
- {{ product.title }}
{% endfor %}

{% assign kitchen_products = collection.products | where: "type", "kitchen" %}

Kitchen products:
{% for product in kitchen_products %}
- {{ product.title }}
{% endfor %}
```

{% endcode %}

{% code title="Output" %}

```
All products:
- Vacuum
- Spatula
- Television
- Garlic press

Kitchen products:
- Spatula
- Garlic press
```

{% endcode %}

You can use a property name with `where` that has no target value when that property is a [boolean](https://shopify.dev/docs/themes/liquid/reference/basics/types#boolean) or [truthy](https://shopify.dev/docs/themes/liquid/reference/basics/true-and-false#truthy). For example, the [`available` property](https://shopify.dev/docs/themes/liquid/reference/objects/product#product-available) of products.

Example

```
{% assign available_products = collection.products | where: "available" %}

Available products:
{% for product in available_products %}
- {{ product.title }}
{% endfor %}
```

### uniq <a href="#uniq" id="uniq"></a>

Removes any duplicate instances of elements in an array.

{% code title="Input" %}

```
{% assign fruits = "orange apple banana apple orange" %}
{{ fruits | split: ' ' | uniq | join: ' ' }}
```

{% endcode %}

{% code title="Output" %}

```
orange apple banana
```

{% endcode %}

## Format filters

### date

Converts a timestamp into a specified date format.

| format | description                                            | example value |
| ------ | ------------------------------------------------------ | ------------- |
| %d     | Two-digit day of the month (with leading zeros)        | `01` to `31`  |
| %m     | Two digit representation of the month                  | `01` to `12`  |
| %y     | Two digit representation of the year                   | `21`          |
| %Y     | Four digit representation for the year                 | `2021`        |
| %H     | Two digit representation of the hour in 24-hour format | `00` to `23`  |
| %I     | Two digit representation of the hour in 12-hour format | `01` to `12`  |
| %p     | Upper-case 'AM' or 'PM' based on the given time        | `AM` or `PM`  |
| %P     | Lower-case 'am' or 'pm' based on the given time        | `am` or `pm`  |
| %M     | Two digit representation of the minute                 | `00` to `59`  |
| %S     | Two digit representation of the second                 | `00` to `59`  |
| %s     | Unix Epoch Time timestamp                              | `1612328167`  |

{% code title="Input" %}

```
{{ order.created_at | date: "%Y-%m-%d %H:%M:%S" }}
```

{% endcode %}

{% code title="Output" %}

```
2021-02-03 04:56:07
```

{% endcode %}

### e164 ⭐

Formats a phone number according to the [E.164 standard](https://en.wikipedia.org/wiki/E.164). If a country calling code is not included in the phone number, then you can pass an [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) country code as an additional parameter.

```
{{ "+1 800 444 4444" | e164 }}
=> +18004444444
```

```
{{ "+44 20 8743 8000" | e164 }}
=> +442087438000
```

```
{{ "020 8743 8000" | e164: "GB" }}
=> +442087438000
```

```
{{ "7325 7731" | e164: "HKG" }}
=> +85273257731
```

To format a phone number associated with a shipping address:

<pre><code><strong>{{ order.shipping_address.phone | e164: order.shipping_address.country_code }}
</strong></code></pre>

### iso3166\_alpha3 ⭐

Converts a two-letter [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) country code to its three-letter equivalent.

```
{{ "US" | iso3166_alpha3 }}
=> USA
```

To format a shipping address country as an ISO 3166 alpha-3 country code:

<pre><code><strong>{{ order.shipping_address.country_code | iso3166_alpha3 }}
</strong></code></pre>

### json

Converts a string, or object, into JSON format.

By default it produces a single-line JSON. You can pass an optional parameter `"pretty"`, to get a multi-line, indented JSON output.

{% hint style="info" %}
The `json` filter is useful for debugging to check what are all available properties of a given object.
{% endhint %}

{% code title="Input" %}

```
{{ order.transacations | json: "pretty" }}
```

{% endcode %}

```
[
    {
        "id": 5689665290299,
        "order_id": 4592641409083,
        "kind": "sale",
        "gateway": "bogus",
        "status": "success",
        "message": "Bogus Gateway: Forced success",
        "created_at": "2022-10-06T10:09:20+02:00",
        "test": true,
        "authorization": "53433",
        "location_id": null,
        "user_id": null,
        "parent_id": null,
        "processed_at": "2022-10-06T10:09:20+02:00",
        "device_id": null,
        "error_code": null,
        "source_name": "web",
        "payment_details": {
            "credit_card_bin": "1",
            "avs_result_code": null,
            "cvv_result_code": null,
            "credit_card_number": "•••• •••• •••• 1",
            "credit_card_company": "Bogus"
        },
        "receipt": {
            "paid_amount": "23.00"
        },
        "amount": "23.00",
        "currency": "USD",
        "admin_graphql_api_id": "gid://shopify/OrderTransaction/5689665290299"
    }
]
```

### json\_parse, parse\_json⭐

Allows parsing string in a format compliant with JSON file requirements into an object. It enables access to individual fields within the object using dot notation.

```
{%- capture material %}
{"properties":{"name":"Cotton","color":"White","structure":"Woven"}}
{%- endcapture %}

{%- assign material = material | json_parse %}

material: {{ material }}
material_json: {{ material | json }}
material_name: {{ material.properties.name }}
```

{% code title="Output" %}

```
material: [object Object]
material_json: {"properties":{"name":"Cotton","color":"White","structure":"Woven"}}
material_name: Cotton
```

{% endcode %}

### moment ⭐

Returns a current or specified time converted to a desired time zone.

The filter has two parameters: a date format and a [time zone identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).

<pre><code><strong>{{ "now" | moment: "YYYY-MM-DD HH:mm:ss", "America/Chicago" }}
</strong><strong>=> 2024-03-13 14:55:00
</strong></code></pre>

| format | description                                            | example value |
| ------ | ------------------------------------------------------ | ------------- |
| DD     | Two-digit day of the month (with leading zeros)        | `01` to `31`  |
| MM     | Two digit representation of the month                  | `01` to `12`  |
| YY     | Two digit representation of the year                   | `21`          |
| YYYY   | Four digit representation for the year                 | `2021`        |
| HH     | Two digit representation of the hour in 24-hour format | `00` to `23`  |
| hh     | Two digit representation of the hour in 12-hour format | `01` to `12`  |
| A      | Upper-case 'AM' or 'PM' based on the given time        | `AM` or `PM`  |
| a      | Lower-case 'am' or 'pm' based on the given time        | `am` or `pm`  |
| mm     | Two digit representation of the minute                 | `00` to `59`  |
| ss     | Two digit representation of the second                 | `00` to `59`  |

## Math filters

Math filters allow you to apply mathematical tasks.

Math filters can be linked and, as with any other filters, are applied in order of left to right. In the example below, `minus` is applied first, then `times`, and finally `divided_by`.Copy

```
You save {{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price }}%
```

### abs <a href="#abs" id="abs"></a>

Returns the absolute value of a number.

{% code title="Input" %}

```
{{ -25 | abs }}
```

{% endcode %}

{% code title="Output" %}

```
25
```

{% endcode %}

`abs` will also work on a string if the string only contains a number.

{% code title="Input" %}

```
{{ "-19.86" | abs }}
```

{% endcode %}

{% code title="Output" %}

```
19.86
```

{% endcode %}

### at\_most <a href="#at_most" id="at_most"></a>

Limits a number to a maximum value.

{% code title="Input" %}

```
{{ 4 | at_most: 5 }}
{{ 4 | at_most: 3 }}
```

{% endcode %}

{% code title="Output" %}

```
4
3
```

{% endcode %}

### at\_least <a href="#at_least" id="at_least"></a>

Limits a number to a minimum value.

{% code title="Input" %}

```
{{ 4 | at_least: 5 }}
{{ 4 | at_least: 3 }}
```

{% endcode %}

{% code title="Output" %}

```
5
4
```

{% endcode %}

### ceil <a href="#ceil" id="ceil"></a>

Rounds an output up to the nearest integer.

{% code title="Input" %}

```
{{ 1.2 | ceil }}
{{ 3.0 | ceil }}
{{ 3.45 | ceil }}
```

{% endcode %}

{% code title="Output" %}

```
2
3
4
```

{% endcode %}

Liquid tries to convert the input to a number before the filter is applied.

{% code title="Input" %}

```
{{ "4.5" | ceil }}
```

{% endcode %}

{% code title="Output" %}

```
5
```

{% endcode %}

### divided\_by <a href="#divided_by" id="divided_by"></a>

Divides an output by a number. The output is rounded down to the nearest integer.

{% code title="Input" %}

```
<!-- product.price = 200 -->
{{ product.price | divided_by: 10 }}
```

{% endcode %}

{% code title="Output" %}

```
20
```

{% endcode %}

### floor <a href="#floor" id="floor"></a>

Rounds an output down to the nearest integer.

{% code title="Input" %}

```
{{ 4.6 | floor }}
{{ 4.3 | floor }}
```

{% endcode %}

{% code title="Output" %}

```
4
4
```

{% endcode %}

### minus <a href="#minus" id="minus"></a>

Subtracts a number from an output.

{% code title="Input" %}

```
<!-- product.price = 200 -->
{{ product.price | minus: 15 }}
```

{% endcode %}

{% code title="Output" %}

```
185
```

{% endcode %}

### modulo <a href="#modulo" id="modulo"></a>

Divides an output by a number and returns the remainder.

{% code title="Input" %}

```
{{ 12 | modulo: 5 }}
```

{% endcode %}

{% code title="Output" %}

```
2
```

{% endcode %}

### plus <a href="#plus" id="plus"></a>

Adds a number to an output.

{% code title="Input" %}

```
<!-- product.price = 200 -->
{{ product.price | plus: 15 }}
```

{% endcode %}

{% code title="Output" %}

```
215
```

{% endcode %}

### round <a href="#round" id="round"></a>

Rounds the output to the nearest integer or specified number of decimals.

{% code title="Input" %}

```
{{ 4.6 | round }}
{{ 4.3 | round }}
{{ 4.5612 | round: 2 }}
```

{% endcode %}

{% code title="Output" %}

```
5
4
4.56
```

{% endcode %}

### times <a href="#times" id="times"></a>

Multiplies an output by a number.

{% code title="Input" %}

```
<!-- product.price = 200 -->
{{ product.price | times: 1.15 }}
```

{% endcode %}

{% code title="Output" %}

```
230
```

{% endcode %}

### to\_fixed

Convert a number into a string, rounding the number to keep only the given number of decimals.

{% code title="Input" %}

```
{{ 1.2345 | to_fixed: 2 }}
```

{% endcode %}

{% code title="Output" %}

```
1.23
```

{% endcode %}

The difference between `round` and `to_fixed` it that `round` returns a number so it trims trailing zeros while `to_fixed` will preserve them.

{% code title="Input" %}

```
{{ 4.5000 | round: 2 }}
{{ 4.5000 | to_fixed: 2 }}
```

{% endcode %}

{% code title="Output" %}

```
4.5
4.50
```

{% endcode %}

## String filters

String filters are used to manipulate outputs and variables of the [string](https://shopify.dev/docs/themes/liquid/reference/basics/types/#strings) type.

### append <a href="#append" id="append"></a>

Appends characters to a string.

{% code title="Input" %}

```
{% assign filename = "/index.html" %}
{{ "website.com" | append: filename }}
```

{% endcode %}

{% code title="Output" %}

```
website.com/index.html
```

{% endcode %}

### base64\_decode <a href="#capitalize" id="capitalize"></a>

Decodes a string to [Base64 format](https://developer.mozilla.org/en-US/docs/Glossary/Base64)

{% code title="Input" %}

```
{{ 'b25lIHR3byB0aHJlZQ==' | base64_decode }}
```

{% endcode %}

{% code title="Output" %}

```
one two three
```

{% endcode %}

### base64\_encode <a href="#capitalize" id="capitalize"></a>

Encodes a string to [Base64 format](https://developer.mozilla.org/en-US/docs/Glossary/Base64)

{% code title="Input" %}

```
{{ 'one two three' | base64_decode }}
```

{% endcode %}

{% code title="Output" %}

```
b25lIHR3byB0aHJlZQ==
```

{% endcode %}

### capitalize <a href="#capitalize" id="capitalize"></a>

Capitalizes the first word in a string

{% code title="Input" %}

```
{{ "title" | capitalize }}
```

{% endcode %}

{% code title="Output" %}

```
Title
```

{% endcode %}

### downcase <a href="#downcase" id="downcase"></a>

Converts a string into lowercase.

{% code title="Input" %}

```
{{ 'UPPERCASE' | downcase }}
```

{% endcode %}

{% code title="Output" %}

```
uppercase
```

{% endcode %}

### escape <a href="#escape" id="escape"></a>

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

{% code title="Input" %}

```
{{ "<p>test</p>" | escape }}
```

{% endcode %}

{% code title="Output" %}

```
&lt;p&gt;test&lt;/p&gt;
```

{% endcode %}

### extract\_number ⭐ <a href="#strip_html" id="strip_html"></a>

Extracts a first number from a string. It works for integers (123), decimal numbers (123.45), and negative numbers (-123). The extracted number is still a text so it doesn't strip leading zeros (0123).

{% code title="Input" %}

```
{%- capture note -%}
Foo 123 Bar 456
{%- endcapture -%}
{{ note | extract_number }}
```

{% endcode %}

{% code title="Output" %}

```
123
```

{% endcode %}

### extract\_numbers ⭐ <a href="#strip_html" id="strip_html"></a>

Extracts all numbers from a string. It works for integers (123), decimal numbers (123.45), and negative numbers (-123). The extracted numbers are still a text to preserve leading zeros (0123).\
The result is an array.

{% code title="Input" %}

```
{%- capture note -%}
Foo 012
Bar 3.4
Baz -56
{%- endcapture -%}
{{ note | extract_numbers | join: " " }}
```

{% endcode %}

{% code title="Output" %}

```
012 3.4 -56
```

{% endcode %}

### md5 <a href="#newline_to_br" id="newline_to_br"></a>

Calculates an MD5 hash from a string.

An example use case for this filter is to calculate a checksum of a request payload, and include it in a request header. Such a checksum is required by some APIs, for example, the [Richard Photo Lab API](https://github.com/richardphotolab/API-Order-docs#checksum).

```
{{ output | strip_all | md5 }}
```

### newline\_to\_br <a href="#newline_to_br" id="newline_to_br"></a>

Inserts a \<br > linebreak HTML tag in front of each line break in a string.

{% code title="Input" %}

```
{% capture var %}
One
Two
Three
{% endcapture %}
{{ var | newline_to_br }}
```

{% endcode %}

{% code title="Output" %}

```
<br />One<br />Two<br />Three<br />
```

{% endcode %}

### prepend <a href="#prepend" id="prepend"></a>

Adds the specified string to the beginning of another string.

{% code title="Input" %}

```
{{ 'sale' | prepend: 'Made a great ' }}
```

{% endcode %}

{% code title="Output" %}

```
Made a great sale
```

{% endcode %}

### remove <a href="#remove" id="remove"></a>

Removes all occurrences of a substring from a string.

{% code title="Input" %}

```
{{ "Hello, world. Goodbye, world." | remove: "world" }}
```

{% endcode %}

{% code title="Output" %}

```
Hello, . Goodbye, .
```

{% endcode %}

### remove\_first <a href="#remove_first" id="remove_first"></a>

Removes only the first occurrence of a substring from a string.

{% code title="Input" %}

```
{{ "Hello, world. Goodbye, world." | remove_first: "world" }}
```

{% endcode %}

{% code title="Output" %}

```
Hello, . Goodbye, world.
```

{% endcode %}

### replace <a href="#replace" id="replace"></a>

Replaces all occurrences of a string with a substring.

{% code title="Input" %}

```
<!-- product.title = "Awesome Shoes" -->
{{ product.title | replace: 'Awesome', 'Mega' }}
```

{% endcode %}

{% code title="Output" %}

```
Mega Shoes
```

{% endcode %}

### replace\_first <a href="#replace_first" id="replace_first"></a>

Replaces the first occurrence of a string with a substring.

{% code title="Input" %}

```
<!-- product.title = "Awesome Awesome Shoes" -->
{{ product.title | replace_first: 'Awesome', 'Mega' }}
```

{% endcode %}

{% code title="Output" %}

```
Mega Awesome Shoes
```

{% endcode %}

### slice <a href="#slice" id="slice"></a>

The `slice` filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.

{% code title="Input" %}

```
{{ "hello" | slice: 0 }}
{{ "hello" | slice: 1 }}
{{ "hello" | slice: 1, 3 }}
```

{% endcode %}

{% code title="Output" %}

```
h
e
ell
```

{% endcode %}

If the passed index is negative, it is counted from the end of the string.

{% code title="Input" %}

```
{{ "hello" | slice: -3, 2  }}
```

{% endcode %}

{% code title="Output" %}

```
ll
```

{% endcode %}

### split <a href="#split" id="split"></a>

The `split` filter takes on a substring as a parameter. The substring is used as a delimiter to divide a string into an array. You can output different parts of an array using [array filters](https://shopify.dev/docs/themes/liquid/reference/filters/array-filters).

{% code title="Input" %}

```
{% assign words = "Hi, how are you today?" | split: ' ' %}

{%- for word in words -%}
{{ word }}
{% endfor %}
```

{% endcode %}

{% code title="Output" %}

```
Hi,
how
are
you
today? 
```

{% endcode %}

### strip <a href="#strip" id="strip"></a>

Strips tabs, spaces, and newlines (all whitespace) from the left and right side of a string.

{% code title="Input" %}

```
{{ '   too many spaces      ' | strip }}
```

{% endcode %}

{% code title="Output" %}

```
too many spaces
```

{% endcode %}

### lstrip <a href="#lstrip" id="lstrip"></a>

Strips tabs, spaces, and newlines (all whitespace) from the **left** side of a string.

{% code title="Input" %}

```
{{ '   too many spaces           ' | lstrip }}!
```

{% endcode %}

{% code title="Output" %}

```
too many spaces           !
```

{% endcode %}

### rstrip <a href="#rstrip" id="rstrip"></a>

Strips tabs, spaces, and newlines (all whitespace) from the **right** side of a string.

{% code title="Input" %}

```
{{ '              too many spaces      ' | rstrip }}!
```

{% endcode %}

{% code title="Output" %}

```
              too many spaces!
```

{% endcode %}

### strip\_all ⭐ <a href="#strip_html" id="strip_html"></a>

Strips tabs, spaces, and newlines (all whitespace) from the entire string.

{% code title="Input" %}

```
{%- capture note -%}
Line 1
   Line 2
      Line 3
{%- endcapture -%}
{{ note | strip_all }}
```

{% endcode %}

{% code title="Output" %}

```
Line 1Line 2Line 3
```

{% endcode %}

### strip\_html <a href="#strip_html" id="strip_html"></a>

Strips all HTML tags from a string.

{% code title="Input" %}

```
{{ "<h1>Hello</h1> World" | strip_html }}
```

{% endcode %}

{% code title="Output" %}

```
Hello World
```

{% endcode %}

### strip\_newlines <a href="#strip_newlines" id="strip_newlines"></a>

Removes any line breaks/newlines from a string.

{% code title="Input" %}

```
{%- capture string_with_newlines -%}
Hello
there
{%- endcapture -%}

{{ string_with_newlines | strip_newlines }}
```

{% endcode %}

{% code title="Output" %}

```
Hellothere
```

{% endcode %}

### truncate <a href="#truncate" id="truncate"></a>

Truncates a string down to the number of characters passed as the first parameter. An ellipsis (...) is appended to the truncated string and is included in the character count.

{% code title="Input" %}

```
{{ "The cat came back the very next day" | truncate: 13 }}
```

{% endcode %}

{% code title="Output" %}

```
The cat ca...
```

{% endcode %}

#### Custom ellipsis <a href="#custom-ellipsis" id="custom-ellipsis"></a>

`truncate` takes an optional second parameter that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.

The length of the second parameter counts against the number of characters specified by the first parameter. For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use 13 for the first parameter of `truncate`, since the ellipsis counts as 3 characters.

{% code title="Input" %}

```
{{ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | truncate: 18, ", and so on" }}
```

{% endcode %}

{% code title="Output" %}

```
ABCDEFG, and so on
```

{% endcode %}

#### No ellipsis <a href="#no-ellipsis" id="no-ellipsis"></a>

You can truncate to the exact number of characters specified by the first parameter and show no trailing characters by passing a blank string as the second parameter:

{% code title="Input" %}

```
{{ "I'm a little teapot, short and stout." | truncate: 15, "" }}
```

{% endcode %}

{% code title="Output" %}

```
I'm a little te
```

{% endcode %}

### truncatewords <a href="#truncatewords" id="truncatewords"></a>

Truncates a string down to the number of words passed as the first parameter. An ellipsis (...) is appended to the truncated string.

{% code title="Input" %}

```
{{ "The cat came back the very next day" | truncatewords: 4 }}
```

{% endcode %}

{% code title="Output" %}

```
The cat came back...
```

{% endcode %}

#### Custom ellipsis <a href="#custom-ellipsis" id="custom-ellipsis"></a>

`truncatewords` takes an optional second parameter that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.

{% code title="Input" %}

```
{{ "The cat came back the very next day" | truncatewords: 4, "--" }}
```

{% endcode %}

{% code title="Output" %}

```
The cat came back--
```

{% endcode %}

#### No ellipsis <a href="#no-ellipsis" id="no-ellipsis"></a>

You can avoid showing trailing characters by passing a blank string as the second parameter:

{% code title="Input" %}

```
{{ "The cat came back the very next day" | truncatewords: 4, "" }}
```

{% endcode %}

{% code title="Output" %}

```
The cat came back
```

{% endcode %}

### upcase <a href="#upcase" id="upcase"></a>

Converts a string into uppercase.

{% code title="Input" %}

```
{{ 'i want this to be uppercase' | upcase }}
```

{% endcode %}

{% code title="Output" %}

```
I WANT THIS TO BE UPPERCASE
```

{% endcode %}

### url\_decode

Decodes a string that has been encoded as a URL or by [url\_encode](#url_encode-1).

{% code title="Input" %}

```
{{ "%27Stop%21%27+said+Fred" | url_decode }}
```

{% endcode %}

{% code title="Output" %}

```
'Stop!' said Fred
```

{% endcode %}

### url\_encode <a href="#url_encode" id="url_encode"></a>

Converts any URL-unsafe characters in a string into percent-encoded characters.

{% code title="Input" %}

```
{{ "john@liquid.com" | url_encode }}
```

{% endcode %}

{% code title="" %}

```
john%40liquid.com
```

{% endcode %}

Note that `url_encode` will turn a space into a `+` sign instead of a percent-encoded character.

{% code title="Input" %}

```
{{ "Tetsuro Takara" | url_encode }}
```

{% endcode %}

{% code title="Output" %}

```
Tetsuro+Takara
```

{% endcode %}

### xml\_escape <a href="#xml_escape" id="xml_escape"></a>

{% hint style="info" %}
This is a special filter available in Exporteo to facilitate the setup of an XML output template.
{% endhint %}

Replaces characters that are special characters in XML documents.

| **Char** | **Escape String** |
| -------- | ----------------- |
| <        | \&lt;             |
| >        | \&gt;             |
| "        | \&quot;           |
| '        | \&apos;           |
| &        | \&amp;            |

{% code title="Input" %}

```
{{ "Jane & Joe O'Neill" | xml_escape }}
```

{% endcode %}

{% code title="Output" %}

```
Jane &amp; Joe O&apos;Neill
```

{% endcode %}


# Whitespace control

Every line of code in a Liquid template produces an LF character at the end of a line. This applies also to lines that don't produce any text.

{% hint style="warning" %}
Controlling whitespace characters, especially newline characters, is crucial in the CSV format.
{% endhint %}

You can include a hyphen in your tag syntax `{{-`, `-}}`, `{%-`, and `-%}` to strip whitespace from the left or right side of a rendered tag.

{% hint style="info" %}
Placing a hyphen in the opening tag `{{-` or `{%-` removes also a newline character at the one of a previous line.
{% endhint %}

For example:

{% code title="Liquid Code" %}

```
{% for item in order.line_items %}
{{ item.title }}
{% endfor %}
```

{% endcode %}

produces the following output (assuming that the `order` contains two line items, a Cap and a T-Shirt):

{% code title="Output" %}

```

Cap

T-Shirt

```

{% endcode %}

Add hyphens to the for-loop tags will remove the empty lines.

{% code title="Liquid Code" %}

```
{%- foritem in order.line_items %}
{{ item.title }}
{%- endfor %}
```

{% endcode %}

{% code title="Output" %}

```
T-Shirt
Cap
```

{% endcode %}

You could place hyphens at the end of the control tags as well to get the same result.

{% code title="Liquid Code" %}

```
{% for item in order.line_items -%}
{{ item.title }}
{% endfor -%}
```

{% endcode %}

However, adding hyphens at both sides of the for-loop tags would also remove line separators between subsequent items reducing the output to one line.

{% code title="Liquid Code" %}

```
{%- for item in order.line_items -%}
{{ item.title }}
{%- endfor -%}
```

{% endcode %}

{% code title="Output" %}

```
T-ShirtCap
```

{% endcode %}


# Useful code snippets

### Add days to the order creation date

If you want to calculate a delivery date by adding a certain number of days to date when an order was placed, then you need to use the following trick.

```liquid
{%- assign three_days_seconds = 3 | times: 24 | times: 60 | times: 60 %}
<DeliveryDate>{{order.created_at | date: "%s" | plus: three_days_seconds | date: "%Y-%m-%d" }}</DeliveryDate>
```

What does the code do?

The first line calculates the number of seconds contained within 3 days. You might have typed 259200 right away, however, calculating it this way makes it easier to modify to a different number of days, and looks less of a magic number.

The second line converts the order creation date to a Unix timestamp , which is the number of seconds since 1970-01-01 00:00:00, adds the calculated number of seconds within the days, and finally converts the date back to a desired format.

### Exclude a specific line item

The recommended way to exclude line items is to use a filter. For example, you can filter out products of a certain vendor, or tagged with a specific tag.

![Exclude line items of vendor X](/files/-MlKH6GWWJjqIIvPWKIc)

![Exclude items tagged with Y](/files/-MlKHccW-yQpcMModfaW)

Make sure that the checkbox "Exclude line items not matching the filter" is enabled.

Nevertheless, if you need a more fine-tuned solution to skip a specific line item, then you can use an `if` statement in the output template code. 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.

{% tabs %}
{% tab title="CSV" %}

```liquid
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 %}
```

{% endtab %}

{% tab title="JSON" %}

```liquid
{
    "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 %}
    ]
}
```

{% endtab %}

{% tab title="XML" %}

```liquid
<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>
```

{% endtab %}
{% endtabs %}

### Get variant options by name

You can use the following code snippet to get variant options by name. The example shows how to get options named `Width`, `Depth`, and `Height`. You can adjust the names to your needs. Please note that option names are case-sensitive (it matters if letters are uppercase or lowercase).

```liquid
{%- for item in order.line_items %}
  <item>
    <width>{{item.options_with_values | where: "name", "Width" | map: "value" }}</width>
    <depth>{{item.options_with_values | where: "name", "Depth" | map: "value" }}</depth>
    <height>{{item.options_with_values | where: "name", "Height" | map: "value" }}</height>
  </item>
{%- endfor %}
```

### Get line item properties by name

Shopify limits the number of variant options to three. If you need to extend the customization of your products, then you can use line items properties. Apps like Infinite Options or Custom Product Builder use line item properties to store customer personalization choices.

The code snippet extracts the Engraving and Gift Wrapping options from line item properties.

```liquid
{%- for item in order.line_items %}
  <item>
    <engraving>{{item.options_with_values | where: "name", "Engraving" | map: "value" }}</engraving>
    <wrapping>{{item.properties | where: "name", "Gift Wrapping" | map: "value" }}</wrapping>
  </item>
{%- endfor %}
```

### Payment date

You can get the payment date from `order.transactions`:

```
{{ order.transactions | where: "kind", "sale" | where: "status", "success" | map: "created_at" | first | date: "%Y-%m-%d" }}
```

### Price after discount

There is no variable for price after discount available directly, however, you can calculate it from `item.price`, `item.discount_allocations`, and `item.quantity`.

If you want to get price after discount for a single item, then you first need calculate the total discount value allocated to the item from `item.discount_allocations`

```liquid
{%- assign total_discount = 0.0 %}
{%- for discount_allocation in item.discount_allocations %}
    {%- assign total_discount = total_discount | plus: discount_allocation.amount %}
{%- endfor %}
```

Then you can calculate the unit discount value by dividing `total_discount` by `item.quantity`

```liquid
{%- assign unit_discount = total_discount | divided_by: item.quantity | round: 2 %}
```

Finally, you can substract the calculated `unit_discount` from `item.price` to get unit price after discount.

```liquid
{%- assign unit_price_after_discount = item.price | minus: unit_discount | round: 2%}
```

Putting the code snippets together to output unit item price per discount:

```liquid
<items>
    {%- for item in order.line_items %}
    <item>
        {%- assign total_discount = 0.0 %}
        {%- for discount_allocation in item.discount_allocations %}
            {%- assign total_discount = total_discount | plus: discount_allocation.amount %}
        {%- endfor %}
        {%- assign unit_discount = total_discount | divided_by: item.quantity | round: 2 %}
        {%- assign unit_price_after_discount = item.price | minus: unit_discount | round: 2 %}
        <unit_price_after_discount>{{ unit_price_after_discount }}</unit_price_after_discount >
    </item>
    {%- endfor %}
</items>
```

On the other hand, if you are looking for **total item price after discount**, then you need to first multiply `item.price` by `item.quantity` and then subtract `total_discount`.

```liquid
<items>
    {%- for item in order.line_items %}
    <item>
        {%- assign total_discount = 0.0 %}
        {%- for discount_allocation in item.discount_allocations %}
            {%- assign total_discount = total_discount | plus: discount_allocation.amount %}
        {%- endfor %}
        {%- assign total_price_after_discount = item.price | times: item.quantity | minus: total_discount | round: 2 %}
        <total_price_after_discount>{{ total_price_after_discount }}</total_price_after_discount>
    </item>
    {%- endfor %}
</items>
```

### Gift card code

If a customer pays for an order by a gift card then the information is recorded in `{{ order.transactions }}`. The transaction `gateway` is then `gift_card`. You can get the ID and last four characters of the gift card code from a transaction `receipt`.

```liquid
{%- assign gift_card_receipt = order.transactions | where: "gateway", "gift_card" | map: "receipt" | first -%}
{{ gift_card_receipt.gift_card_id }}
{{ gift_card_receipt.gift_card_last_characters }}lo
```

### Total weight

If you export all items, then you can just use the `{{ order.total_weight }}` variable.

However, if you specified a filter, and selected the option to exclude items not matching the filter, then you'll need to calculate the total weight using the following code snippet.

```liquid
{%- assign total_grams = 0 -%}
{%- for line_item in order.line_items -%}
    {%- assign line_item_total_grams = line_item.grams | times: line_item.quantity -%}
    {%- assign total_grams = total_grams | plus: line_item_total_grams -%}
{%- endfor -%}
{{ total_grams }}
```

### Shipping tax

When it comes to shipping cost, Shopify gives you only the total shipping price in the `order.total_shipping_price_set` variable which may or may not include taxes depending on the value of `order.taxes_included`. There is no variable that would hold shipping tax or a corresponding net/gross shipping price. To get the tax amount of the shipping cost, you'll need to calculate it from `order.shipping_lines` this way:

```liquid
{%- assign shipping_tax = 0 %}
{%- for shipping_line in order.shipping_lines %}
    {%- for shipping_tax_line in shipping_line.tax_lines %}
        {%- assign shipping_tax = shipping_tax | plus: shipping_tax_line.price %}
    {%- endfor %}
{%- endfor %}

{{ shipping_tax }}
```

### Barcode image

Using Exporteo, you can generate a pick list PDF that includes barcode images which your logistics service can scan to speed up order fulfillment. To embed a barcode image you need to add the following code to the default PDF template:

```
<td><img src="https://barcode.tec-it.com/barcode.ashx?data={{line_item.variant.barcode}}&code=UPCA"/></td>
```

As you may notice, it makes use of an external service to generate the barcode image. Nevertheless, the TEC-IT barcode generator is a free service.

Here is an example preview of an order that includes UPC barcodes:

![](/files/JSuZyEhvR0Z4BzO002bM)

### Refunded line items

You can get a list of refunded line items from `order.refunds`.

```liquid
{
    "refund_line_items": [
    {%- assign refund_line_items = order.refunds | flat_map: "refund_line_items" -%}
    {%- for refund_line_item in refund_line_items -%}
    {
      "sku": "{{ refund_line_item.line_item.sku }}",
      "quantity": "{{ refund_line_item.quantity }}",
      "restock_type": "{{ refund_line_item.restock_type }}",
      "subtotal": "{{ refund_line_item.subtotal }}"
    }
    {%- if forloop.last == false -%},{% endif %}
    {%- endfor %}]
}
```

An order may be refunded partially more than once. Each refund has a list of `refund_line_items`. The code snippet above leverages the [flat\_map](/liquid/liquid-filters#flat_map) filter to get a single list of refunded line items from all refunds.

###


# Multipart requests

Some APIs require payload encoded as `multipart/form-data`. To send multipart requests from Exporteo, you need to add a `Content-Type` header set to `multipart/form-data; boundary=ExporteoFormBoundary`.

<figure><img src="/files/eAYaTSBAzy37fZPfoBpc" alt=""><figcaption></figcaption></figure>

You also need to insert the multipart boundaries to the output template like in the code snippet below. The example includes three parts: username, password, and an xml file named `orderxml`. Please make sure to preserve the empty lines below each `Content-Disposition`.

```
--ExporteoFormBoundary
Content-Disposition: form-data; name="username"

store1234
--ExporteoFormBoundary
Content-Disposition: form-data; name="password"

o2qoTH91NDe6uqa
--ExporteoFormBoundary
Content-Disposition: form-data; name="orderxml"

<?xml version="1.0"?>
<order>
  ...
</order>
--ExporteoFormBoundary--
```


# Automatic retries

There are various reasons that your orders might be not exported on the the first try. The server that you want to send the orders to may be temporarily down or inaccessible due to a network problem.

In case of any failure, Exporteo retries to export an order up to 10 times with an increasing delay. The delay between subsequent attempts grows exponentially (2ⁿ - 1). The first retry takes place after 1 minute, second attempt 3 minutes after the first retry, third after 7 minutes, and so on. The last attempt occurs around 17 hours after the first failed export.

The maximum number of attempts for bulk exports depends on the selected schedule. Hourly automations are being re-run up to 5 times because more attempts would overlap the next scheduled run. Daily and less frequent automations are being retried up to 10 times.

<table><thead><tr><th width="180" align="center">Attempt</th><th align="right">Delay from previous attempt</th><th align="right">Delay from first attempt</th></tr></thead><tbody><tr><td align="center">1</td><td align="right"></td><td align="right"></td></tr><tr><td align="center">2</td><td align="right">1 minute</td><td align="right">1 minute</td></tr><tr><td align="center">3</td><td align="right">3 minutes</td><td align="right">4 minutes</td></tr><tr><td align="center">4</td><td align="right">7 minutes</td><td align="right">11 minutes</td></tr><tr><td align="center">5</td><td align="right">15 minutes</td><td align="right">26 minutes</td></tr><tr><td align="center">6</td><td align="right">31 minutes</td><td align="right">57 minutes</td></tr><tr><td align="center">7</td><td align="right">1 hour 3 minutes</td><td align="right">2 hours</td></tr><tr><td align="center">8</td><td align="right">2 hours 7 minutes</td><td align="right">4 hours 7 minutes</td></tr><tr><td align="center">9</td><td align="right">4 hours 15 minutes</td><td align="right">8 hours 22 minutes</td></tr><tr><td align="center">10</td><td align="right">8 hours 31 minutes</td><td align="right">16 hours 53 minutes</td></tr></tbody></table>


# Post-processing

Exporteo allows adding the order tag or updating the order note field, order metafield, as well as the customer metafield after a successful order export.

{% hint style="info" %}
You can use Liquid formulas in all fields described in this section.
{% endhint %}

### Tag order

Check the option *Tag exported orders with* and provide a tag to be added. Previous tags will not be overwritten.

<figure><img src="/files/7NQpflMwnnb0IEdKytUq" alt=""><figcaption><p>Tag an order after a successful export</p></figcaption></figure>

To add more tags, separate them with commas:

<figure><img src="/files/dXs6jGbL1jgGhdmaQH7N" alt=""><figcaption><p>Add multiple order tags</p></figcaption></figure>

You can use Liquid with variables related to an order to add tags conditionally:

<figure><img src="/files/UGoJqNyewhTc99SVWEIf" alt=""><figcaption><p>Tag orders conditionally</p></figcaption></figure>

### Order note

Unlike tags, Exporteo overwrites the content of the order note field. To keep its previous content and add new information, use the variable `{{ order.note }}`

<figure><img src="/files/2J22ZfodoxX6NX0fP5fZ" alt=""><figcaption><p>Update order notes</p></figcaption></figure>

### Order metafield

Exporteo allows updating the order metafield after a successful export. This can be particularly useful when an order is transmitted via API, and there is a need to save the order ID created in the supplier's system.

<figure><img src="/files/pAt7Q6fkyBO9Mljn9wkf" alt=""><figcaption><p>Update order metafield</p></figcaption></figure>

Available only for the HTTP destination channel.

### Customer metafield

Exporteo enables you to update the order metafield after a successful export. You can use this option when you need to save the customer's ID from the supplier's system.

<figure><img src="/files/DnbnP9RsGZrMYyhaTKzI" alt=""><figcaption><p>Update customer metafield</p></figcaption></figure>

Available only for the HTTP destination channel. Requires adding `write_customers` scope to Exporteo.

### Save the value of a field from the API response

You can save the value of a specific field from the API response as a tag, order note, order metafield, or customer metafield. To do that use a Liquid formula. The entire response is stored in the `response` object. To fetch the value from a specific field use a dot notation, e.g.: `{{ response.customer.customer_id }}`

{% code title="API sample response" %}

```json
{
  "supplier_id": "12345",
  "order_id": "67890",
  "customer": {
    "customer_id": "09876"
  },
  "status": "Confirmed",
  "items": [
    {
      "product_id": "ABC123",
      "name": "Wireless Mouse",
      "quantity": 2,
      "price_per_unit": 25.99,
      "total_price": 51.98
    },
    {
      "product_id": "XYZ456",
      "name": "Keyboard",
      "quantity": 1,
      "price_per_unit": 45.99,
      "total_price": 45.99
    }
  ],
  "shipping": {
    "method": "Standard",
    "estimated_delivery_date": "2024-12-30"
  },
  "total_order_price": 97.97,
  "currency": "USD"
}
```

{% endcode %}


# FAQ

### How does Exporteo handle failed exports?

*What happens if the external server is offline or inaccessible temporarily? Does Exporteo keep trying until it is successful, or will that export simply be lost?*

In case of any error, Exporteo retries to export an order up to 10 times. Find out more details on the [automatic retries](/automatic-retries) page.

### Is it possible to sync old orders? <a href="#reprocess-selected-orders" id="reprocess-selected-orders"></a>

Exporteo allows existing orders to be processed if they are not older than 60 days. Navigate to the **Orders** section of your Shopify dashboard. Select the orders you want to sync. A bar appears at the top of the list. Click the button with the **three dots** and pick the option **Process in Exporteo**. Next, select an automation you want to use for the export and hit **Start**.

<figure><img src="/files/SHD9HwacMN51ZIzQoED8" alt="Reprocess selected orders in Exporteo animated"><figcaption><p>Reprocess selected orders in Exporteo</p></figcaption></figure>

### How to exclude removed items?

Shopify retains removed items in the order data and preserves their original quantity. The `current_quantity` property represents the line item quantity after subtracting any removed units.

To exclude removed items, add a conditional statement that checks whether `current_quantity > 0`.

```
{%- for item in order.line_items %}
{%- if item.current_quantity > 0 %}
...
{%- endif %}
{%- endfor %}
```

### How to add our brand logo to the PDF invoice?

You can add an `<img>` element linked to the logo image hosted on your website.

```
<img src="https://website.com/images/logo.png" style="width: 200px">
```

![](/files/-MOm6-VmopHvcTeivbih)

If you have your logo in SVG format then you can insert it directly as an `<svg>` element in the output template.

![](/files/-MOm641dHIdXMIcwWMN5)

You can switch to the preview mode to check if the logo looks good.

![](/files/-MOm6MZWSbZtWCXR8CXE)

### How to add multiple sheets to an Excel file

You can include different order data in separate sheets when exporting orders as Excel files.

To create a new sheet in the template, use the following syntax:

```
=== Sheet1 ===
{%- comment %} Sheet1 template {%- endcomment %}
=== Sheet2 ===
{%- comment %} Sheet2 template {%- endcomment %}
```

Each time you use `=== SheetName ===`, the app will start a new sheet with the specified name. Add your column headers and data lines below this command, just like in a standard Excel export template.

```
=== Order Info ===
Order Number,Customer Name,Address,Postal Code,City
{{ order.name -}},
{{- order.shipping_address.name -}},
{{- order.shipping_address.street -}},
{{- order.shipping_address.zip -}},
{{- order.shipping_address.city }}
=== Order Items ===
SKU,Quantity,Price
{%- for line_item in order.line_items %}
{{ line_item.sku -}},
{{- line_item.quantity -}},
{{- line_item.price -}},
{%- endfor %}
```

<figure><img src="/files/nOf3sIQJrIYinNcLcoY2" alt=""><figcaption><p>Exporting order data into separate Excel sheets with Exporteo</p></figcaption></figure>


# Get support

If you need any help please contact us at <exporteo@solvenium.com>


