# Twig-Variablen & Beispiele

In den Twig-Editoren (Positionstabelle und Zusammenfassung) stehen die üblichen Variablen der Shopware-Dokument-Templates zur Verfügung. Diese Seite fasst die wichtigsten zusammen.

## Verfügbarkeit je Editor

| Variable          |  Positionstabelle | Zusammenfassung |
| ----------------- | :---------------: | :-------------: |
| `order`           |         ✅         |        ✅        |
| `lineItems`       | – (über Schleife) |        ✅        |
| `lineItem`        |  ✅ (je Position)  |        –        |
| `config`          |         ✅         |        –        |
| `hueRenderPhase`  |         ✅         |        –        |
| `currencyIsoCode` |         ✅         |  selbst setzen  |
| `languageId`      |         ✅         |        –        |
| `billingAddress`  |         ✅         |        –        |

> Die Zusammenfassung wird serverseitig gerendert und erhält nur `order` und `lineItems`. Hilfsvariablen wie `currencyIsoCode` setzen Sie dort selbst, z. B. `{% set currencyIsoCode = order.currency.isoCode %}`.

## Bestellung (`order`)

| Ausdruck                                                | Beschreibung                      |
| ------------------------------------------------------- | --------------------------------- |
| `order.orderNumber`                                     | Bestellnummer                     |
| `order.amountNet`                                       | Nettosumme der Bestellung         |
| `order.amountTotal`                                     | Bruttosumme der Bestellung        |
| `order.price.totalPrice`                                | Gesamtsumme                       |
| `order.price.rawTotal`                                  | Rohsumme (vor Rundung)            |
| `order.price.calculatedTaxes.sortByTax`                 | Steuern, sortiert nach Steuersatz |
| `order.price.taxStatus`                                 | `gross` oder `net`                |
| `order.shippingTotal`                                   | Versandkosten                     |
| `order.currency.isoCode`                                | Währungs-ISO-Code (z. B. `EUR`)   |
| `order.deliveries.first.shippingMethod.translated.name` | Name der Versandart               |
| `order.deliveries.first.getShippingOrderAddress`        | Lieferadresse                     |
| `order.totalRounding`, `order.itemRounding`             | Rundungseinstellungen             |

## Position (`lineItem`)

| Ausdruck                         | Beschreibung                           |
| -------------------------------- | -------------------------------------- |
| `lineItem.label`                 | Bezeichnung                            |
| `lineItem.quantity`              | Menge                                  |
| `lineItem.unitPrice`             | Einzelpreis                            |
| `lineItem.totalPrice`            | Gesamtpreis der Position               |
| `lineItem.payload.productNumber` | Produktnummer                          |
| `lineItem.payload.options`       | Variantenoptionen (`group` / `option`) |
| `lineItem.payload.features`      | Produkt-Features (z. B. Grundpreis)    |
| `lineItem.price.taxRules`        | Steuersätze der Position               |

## Konfiguration (`config`)

| Ausdruck                               | Beschreibung                       |
| -------------------------------------- | ---------------------------------- |
| `config.displayLineItems`              | Positionen anzeigen?               |
| `config.displayPrices`                 | Preise anzeigen?                   |
| `config.displayLineItemPosition`       | Positionsnummer anzeigen?          |
| `config.displayAdditionalNoteDelivery` | Zusatzhinweis bei Lieferung        |
| `config.deliveryCountries`             | Lieferländer (IDs)                 |
| `config.fileType`                      | Dateityp des gerenderten Dokuments |

## Nützliche Filter

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

## Beispiel: Variantenoptionen einer Position ausgeben

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

## Beispiel: Steuersätze einer Position ausgeben

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

> **Tipp:** Da die mitgelieferten Standardvorlagen exakt dem Shopware-Standardlayout entsprechen, sind sie die beste Referenz für verfügbare Variablen und deren Verwendung. Laden Sie die Standardvorlage und arbeiten Sie sich von dort aus vor.


---

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

```
GET https://docs.hubyte.de/pdf-dokumenten-template-bearbeiten/twig-variablen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
