> For the complete documentation index, see [llms.txt](https://docs.hubyte.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hubyte.de/pdf-dokumenten-template-bearbeiten/english-documentation/twig-variablen.md).

# Twig variables & examples

In the Twig editors (line items table and summary) the usual variables of the Shopware document templates are available. This page summarizes the most important ones.

## Availability per editor

| Variable          | Line items table |     Summary     |
| ----------------- | :--------------: | :-------------: |
| `order`           |         ✅        |        ✅        |
| `lineItems`       |   – (via loop)   |        ✅        |
| `lineItem`        | ✅ (per position) |        –        |
| `config`          |         ✅        |        –        |
| `hueRenderPhase`  |         ✅        |        –        |
| `currencyIsoCode` |         ✅        | set it yourself |
| `languageId`      |         ✅        |        –        |
| `billingAddress`  |         ✅        |        –        |

> The summary is rendered server-side and only receives `order` and `lineItems`. Set helper variables such as `currencyIsoCode` yourself there, e.g. `{% set currencyIsoCode = order.currency.isoCode %}`.

## Order (`order`)

| Expression                                              | Description                    |
| ------------------------------------------------------- | ------------------------------ |
| `order.orderNumber`                                     | Order number                   |
| `order.amountNet`                                       | Net total of the order         |
| `order.amountTotal`                                     | Gross total of the order       |
| `order.price.totalPrice`                                | Grand total                    |
| `order.price.rawTotal`                                  | Raw total (before rounding)    |
| `order.price.calculatedTaxes.sortByTax`                 | Taxes, sorted by tax rate      |
| `order.price.taxStatus`                                 | `gross` or `net`               |
| `order.shippingTotal`                                   | Shipping costs                 |
| `order.currency.isoCode`                                | Currency ISO code (e.g. `EUR`) |
| `order.deliveries.first.shippingMethod.translated.name` | Name of the shipping method    |
| `order.deliveries.first.getShippingOrderAddress`        | Delivery address               |
| `order.totalRounding`, `order.itemRounding`             | Rounding settings              |

## Position (`lineItem`)

| Expression                       | Description                              |
| -------------------------------- | ---------------------------------------- |
| `lineItem.label`                 | Label                                    |
| `lineItem.quantity`              | Quantity                                 |
| `lineItem.unitPrice`             | Unit price                               |
| `lineItem.totalPrice`            | Total price of the position              |
| `lineItem.payload.productNumber` | Product number                           |
| `lineItem.payload.options`       | Variant options (`group` / `option`)     |
| `lineItem.payload.features`      | Product features (e.g. reference price)  |
| `lineItem.product.ean`           | EAN of the product (since version 4.2.2) |
| `lineItem.product.parent`        | Parent product of a variant              |
| `lineItem.price.taxRules`        | Tax rates of the position                |

## Configuration (`config`)

| Expression                             | Description                        |
| -------------------------------------- | ---------------------------------- |
| `config.displayLineItems`              | Display positions?                 |
| `config.displayPrices`                 | Display prices?                    |
| `config.displayLineItemPosition`       | Display position number?           |
| `config.displayAdditionalNoteDelivery` | Additional delivery note           |
| `config.deliveryCountries`             | Delivery countries (IDs)           |
| `config.fileType`                      | File type of the rendered document |

## Useful filters

| Filter             | Description                                |
| ------------------ | ------------------------------------------ |
| \`{{ value         | currency(currencyIsoCode, languageId) }}\` |
| \`{{ value         | sw\_sanitize }}\`                          |
| \`{{ 'snippet.key' | trans }}\`                                 |

## Example: output the variant options of a position

```twig
{% if lineItem.payload.options|length >= 1 %}
    <br/>
    {% for option in lineItem.payload.options %}
        {{ option.group|sw_sanitize(null, true) }}: {{ option.option|sw_sanitize(null, true) }}
        {% if lineItem.payload.options|last != option %} {{ " | " }} {% endif %}
    {% endfor %}
{% endif %}
```

## Example: output the EAN of a position

Since version 4.2.2, `lineItem.product` provides the ordered product with all its fields (e.g. `ean`, `manufacturerNumber`). If a variant inherits the EAN from its parent product, it is available under `lineItem.product.parent`:

```twig
{% set ean = lineItem.product.ean ?: lineItem.product.parent.ean %}
{% if ean %}
    <br/>EAN: {{ ean }}
{% endif %}
```

> **Note:** If the product was deleted after the order was placed, `lineItem.product` is empty. The current product data is always output, not the state at the time of the order.

## Example: output the tax rates of a position

```twig
{% for tax in lineItem.price.taxRules %}
    {{ tax.taxRate }} %{% if loop.last %}{% else %}<br>{% endif %}
{% endfor %}
```

> **Tip:** Since the bundled default templates match Shopware's standard layout exactly, they are the best reference for available variables and their usage. Load the default template and work your way forward from there.
