How to generate Prestashop Invoice by Customer name?

Objective of the blog

After reading this blog we will be able to generate the invoice PDF by customer name.

Problem Statement

Currently,  the invoice is generated using the date on which invoice is first created.  So, we can replace the date to the customer’s name before generating the invoice.


We need to modify the below files to fix the same. We will be overriding the corresponding function and definition of class file to avoid any changes in Core files.
Below are the list of class files which will be overrided-


Procedure to Solve the issue-

1. Create file HTMLTemplateInvoice.php file on path override\classes\pdf and put below code in it. This will save generate the filename of the invoice.

* @override HTMLTemplateInvoice.php

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
* Returns the template filename
* @return string filename
public function getFilename()
$id_lang = Context::getContext()->language->id;
$id_shop = (int)$this->order->id_shop;
$format = '%1$s%2$06d';

if (Configuration::get('PS_INVOICE_USE_YEAR')) {
$format = Configuration::get('PS_INVOICE_YEAR_POS') ? '%1$s%3$s-%2$06d' : '%1$s%2$06d-%3$s';

/* changes started
* to add the customer name
$customer = new Customer((int)$this->order->id_customer);
return sprintf(
Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop),
date('Y', strtotime($this->order_invoice->date_add))

/* changes end*/


2. After creating the php file in the override folder. Clear the cache from the Back-office-> Advance Parameter -> Performance.

3. Now, generate the invoice by navigating to the Back-office-> Orders.

Refer below screenshots


Prestashop Invoice


Prestashop Invoice


Prestashop Invoice

Click here to download the complete project.


After following the above procedure, you will be able to modify the invoice name.

Mayank Kumar

Mayank Kumar

Mayank Kumar with 2.5 years of experience as Software Engineer working on Knowband. Being a Computer Science graduate loves to face challenges, explore new things and self-motivator.

Leave a Reply

Your email address will not be published. Required fields are marked *