PDF documents & variables
The filled-in fields can also be output on PDF documents (invoice, delivery note, credit note, cancellation invoice). The plugin already includes an extension of the standard document template – but you can also customize the output in your own template.
Enabling the default output
For a field to appear on documents, the Show in order documents option must be enabled in the field settings (see Creating fields & field types). The plugin then outputs the attributes automatically per order line item:
Without a price – Name of the attribute and the selected value (for color selection the color name).
With a price – Name, selected option, quantity, tax rate, unit and total price of the surcharge.
The presentation follows Shopware's document options (e.g. config.displayPrices, config.displayLineItemPosition).
Available variables per order line item
On documents the line item variable is called lineItem. The fields are stored in the payload – just like in the email:
lineItem.payload.huebert_attributes
All filled-in fields without a separate price.
lineItem.payload.attributes_with_prices
Fields/options with a surcharge (only when "prices" are enabled).
lineItem.payload.dependencies
Fields confirmed via a dependency (checkbox), incl. price.
In addition, these standard variables are useful in the document template:
lineItem.quantity
Quantity of the line item.
lineItem.unitPrice / lineItem.totalPrice
Unit and total price of the line item.
lineItem.price.taxRules.first.taxRate
Tax rate of the line item.
currencyIsoCode
Currency ISO code (for the currency filter).
config.displayPrices
Document option: show prices.
config.displayLineItemPosition
Document option: show position number.
The exact structure of huebert_attributes and attributes_with_prices is identical to the email – see Email template & variables.
Customizing the document template
If you want to design the presentation yourself, override the position block in the document template. You have two options:
Own theme/plugin – Create a file
views/documents/base.html.twigthat extends@Framework/documents/base.html.twig.Plugin "Edit document template" (
HuebertCustomDocuments) – Lets you adapt the templates directly in the administration without creating your own files.
Template: extend the position block
Examples
Output only a specific field on the delivery note
Subtract surcharges from the line item price
If the document should show the plain product price without the surcharges, you can calculate the sum of the attribute prices and subtract it from the line item price (analogous to the shipped template):
Tip: After every template change, generate a test document for a real order to check the presentation. Make sure
currencyIsoCodeis set before using thecurrencyfilter – in the standard document template the variable is already available.
Zuletzt aktualisiert