Skip to main content

Customize offer document (optional)

The Shopware default component for PDF document generation is used to create the offer PDF. You can find the corresponding configuration under Settings → Basic Settings → Shop Settings → PDF document generation. Here you can customize the document to your requirements by using a custom template file. The template extends the Shopware default invoice template index.tpl. As a result, the template inherits the basic structure and styling of the invoice template.

Here you can find Shopware's guide on creating or customizing PDF documents.

Create or customize a template file

  • Create a .tpl file in the folder themes/Frontend/Bare/documents or in the folder of the theme you are using for documents with the following content:

    {extends file="documents/offer.tpl"}
    {namespace name="documents/viison_offer_management/offer"}
  • Alternatively, you can also open the existing template file for the offer PDF at:
    /engine/Shopware/Plugins/Community/Backend/ViisonOfferManagement/Views/documents/offer.tpl

  • Following the standard Shopware logic for document extension, you can now add custom fields. For custom fields per line item on the document, extra_fields blocks are provided.

  • Every column of the table (header row and content) can be extended or replaced by blocks.

  • Within the table (block name="document_index_table_each") you have access to the product information of the respective offer line item via {$position.articleDetail} [instance of the Shopware model Shopware\Models\Article\Detail]. Please note that product information is not necessarily available for every offer line item. When accessing the product information of an offer line item, you should therefore always check first whether it is available:

    {if $position.articleDetail}{$position.articleDetail->getNumber()}{/if}
  • Finally, in the PDF document generation settings, you only need to replace the name of the “template” with the name of the new .tpl file.

  • Important: The file you create must NOT be named offer.tpl.

Please note that after successfully customizing the document template, the preview function in Shopware's PDF document generation for the offer PDF may not work correctly under certain circumstances. However, the PDF is still generated correctly when the offer is created.

Did this answer your question?