Blog navigation

Blog Rss rss_feed

PDF Templates in PrestaShop: How to Customize and Override Without Losing Changes After an Update

PDF Templates in PrestaShop: How to Customize and Override Without Losing Changes After an Update

In PrestaShop, customer interaction often involves sending emails with attached PDF files. For example, with every order, the customer receives a PDF invoice as a confirmation of the purchase. It's often necessary to customize these files to meet the specific needs of a store, improving the user experience and making it unique.

What Are PDF Files Used for in PrestaShop?

PDF files play a crucial role in the document workflow of an online store. They are used for:

  • Issuing invoices;
  • Creating delivery slips;
  • Handling merchandise returns;
  • Generating supply orders and other documents.

Each of these PDF documents is automatically generated by the PrestaShop system, and it has a template that can be customized to reflect the unique features of your store, such as logos, additional fields, or a specific format.

How Are PDF Templates Structured in PrestaShop?

PrestaShop uses Smarty templates and the TCPDF engine to generate PDF files. The templates are located in the /pdf folder and contain a set of .tpl files that define the structure and styling of the documents.

Here are examples of invoice templates:

  • invoice.tpl — the main invoice template;
  • invoice.product-tab.tpl — responsible for displaying the products;
  • invoice.total-tab.tpl — responsible for displaying totals.

How to Override PDF Templates

PrestaShop offers two ways to modify PDF templates:

  1. Modifying core files — this is not recommended because any changes you make may be lost during a PrestaShop update.
  2. Overriding templates in the theme — the safest method, which ensures that your changes remain intact after system updates.

To override the templates, you need to copy the required files from the /pdf folder to your theme's /themes/your-theme/pdf directory. After that, you can modify the templates without worrying that your changes will be erased during the next update.

Note that it is not possible to override PDF templates in a module—this can only be done through the theme.

PDF Template Examples

For each document type, PrestaShop uses a separate set of template files:

  1. Delivery slips — templates are found in /pdf/delivery-slip.tpl, /pdf/delivery-slip.product-tab.tpl, and other files.
  2. Invoices — files are located in /pdf/invoice.tpl, /pdf/invoice.product-tab.tpl, and so on.
  3. Merchandise returns — files such as /pdf/order-return.tpl, /pdf/order-return.product-tab.tpl, and others are used.

Customizing and Optimizing PDF Templates

Once the template files are copied to your theme's folder, you can begin customizing them. This might include:

  • Modifying how fields are displayed in the templates;
  • Adding new elements, such as text messages or images;
  • Styling the elements with CSS so that the PDF document looks attractive and matches your brand’s style.

Overriding PDF templates in PrestaShop is an important step in personalizing your online store. It allows you to create unique documents that meet your specific requirements and reflect your brand's identity.

Feel free to share in the comments whether you’ve worked with PDF files in PrestaShop and if you’d like to see an article about customizing individual elements in PDF documents.

Was this blog post helpful to you?

    
👈 Присоединяйтесь к нашему Telegram-каналу!

Будьте в курсе последних новинок и фишек e-commerce: советы, полезные инструменты и эксклюзивные материалы.

No comments at this moment
close

Checkout

close

Favourites