> For the complete documentation index, see [llms.txt](https://galmis.gitbook.io/serializer-product-tracking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://galmis.gitbook.io/serializer-product-tracking/getting-started/sharing-and-integration/development-api-reference/order-printers-liquid-variables-and-filters.md).

# Order printer's Liquid variables and filters

{% hint style="warning" %}
The app provides its own variation of Shopify's [Liquid templating language](https://shopify.github.io/liquid/) variables and filters. Please do not confuse it with the variables and filters available in Shopify notifications, storefront's theme, etc.
{% endhint %}

{% hint style="info" %}
The official [Shopify Order Printer](https://apps.shopify.com/shopify-order-printer) app now supports order metafields via `order.metafields` Liquid variable. For example,

```liquid
{% assign tracked_line_items = order.metafields.serializer.properties.items
              | where: 'lineItemId', line_item.id
            %}
  
            {% if tracked_line_items.size > 0 %}
              {% assign sns = tracked_line_items | where: 'serialNumber' | map: 'serialNumber' %}
              {% if sns.size > 0 %}
                <small> Serial number(s): {{ sns | join: ', ' }} </small>
              {% endif %}
            {% endif %}
```

The Shopify Order Printer may be a better alternative than Serializer's order printer.&#x20;

Please check out [Liquid variables and filters reference for Shopify Order Printer](https://help.shopify.com/en/manual/fulfillment/managing-orders/printing-orders/shopify-order-printer/liquid-variables-and-filters-reference) for more details.&#x20;
{% endhint %}

## Variables

The app provides variables derived/enriched from the data available in Shopify APIs.  Such variables are prefixed with two underscore symbols "\_\_", e.g. `{{ order.__metafields }}`. All available variables and their values can be previewed when creating or editing a template.

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

### Order

#### Admin REST API

The app queries the data from Shopify's Order [REST Admin API](https://shopify.dev/docs/api/admin-rest/2023-10/resources/order#resource-object). The order resource data is available inside the `order` variable with the same property names as documented in Shopify API's documentation. For example, the order `note` field that appears in the REST order resource documentation,

&#x20;![](/files/RoU9jomNTsPEoxBGBW82)&#x20;

can be embedded in your template via `{{ order.note }}` syntax. Similarly, you could use other fields such as `line_items`, `name`, `total_price`, etc.

{% hint style="info" %}
The app shares most of the data. If there are any properties in the Shopify API's documentation not available in the app, please contact me and I'll add the missing properties.&#x20;
{% endhint %}

#### Enriched order fields

**Order money fields**

{% hint style="info" %}
Money fields postfixed with \_set contains prices in presentment (customer's) and shop currencies in the format defined in Shopify order resource's documentation. ![](/files/7oq17xCHaoeu5nG4Oz1q)

For convenience, the app also provides their numeric equivalents in presentment currency fields without the \_set postfix. For example, `__total_refunded` is a numeric presentment money amount of `__total_refunded_set.`
{% endhint %}

* `__total_refunded_set`: a total sum of all `subtotal_set` within all available order refund `refund_line_items` for all`order.refunds`.
* `__net_payment_set`: `order.current_total_price` minus `order.total_outstanding`.
* `__total_outstanding_set`: `order.total_outstanding` converted to a Shopify money bag containing amounts in shop and presentment currencies.

**Order line\_items money fields**

* `__discounted_unit_price_set`: order line's `price_set` minus all `amount_set` from line's `discount_allocations.`
* `__total_discount_set`: a sum of all line's `discount_allocations`'`amount_set`s.
* `__original_total_set`: line's `price_set` multiplied by `quantity`.
* `__discounted_total_set`: `__original_total_set` minus `__total_discount_set`.
* `__current_final_price_set`:  line's`__discounted_unit_price_set` multiplied by line's  `__current_quantity`.

**Other order line\_items fields**

* `__current_quantity`: line item's `quantity` minus all quantity from line's `refund_line_items`.
* `__serializer_items`: an array of unique serializer items for that specific order line item sourced for serializer's order metafield. Serializer item contains fields such as `serialNumber` , `warrantyDuration`, `customFields`, etc., which are documented in <https://galmis.gitbook.io/serializer-product-tracking/getting-started/development-api-reference/metafields#order>.

**Other order fields**

* `__metafields` - extracted from the [Shopify Metafields REST API](https://shopify.dev/docs/api/admin-rest/2023-10/resources/metafield). Metafields can be accessed via `order.__metafields.[metafield namespace here].[metafield key here]`, e.g. `order.__metafields.serializer.properties`.

### Shop

The shop resource is currently limited to the following fields sourced from the [Graphql Admin API](https://shopify.dev/docs/api/admin-graphql/2023-10/objects/Shop):

* name
* contact\_email
* primary\_domain
* myshopify\_domain
* billing\_address

{% hint style="info" %}
For consistency the variable naming format matches the one of REST API and other Shopify Liquid flavours, i.e. the camel case converted to the snake case. For example, Graphql's contactEmail is available via `{{ shop.contact_email }}` Liquid variable.
{% endhint %}

## Filters

Apart from the filters built in the [Liquid language](https://shopify.github.io/liquid/), the app also provides a few convenience filters:

* `money`: formats a presentment (customer's) money field in the format of order's `customer_locale`. The filter accepts Shopify money bag fields, e.g. `{{ order.total_price_set | money }}` or numeric presentment money equivalent (without the \_set), e.g. `{{ order.total_price | money }}`.
* format\_address: formats an address into an HTML string (similar to Shopify's equivalent filter) with address lines separated by the line break `<br>` HTML tag. Example use: `{{ shop.billing_address | format_money }}`.

{% hint style="info" %}
Thank you for following the guide. If there are any filters or data fields not available in the app, please email me at <hello@galmis.com>. If technically possible, I'm happy to add them with no extra cost.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://galmis.gitbook.io/serializer-product-tracking/getting-started/sharing-and-integration/development-api-reference/order-printers-liquid-variables-and-filters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
