'' Generare la fattura Prestashop in base al nome del cliente 2024 '' ''

How to generate PrestaShop Invoice by Customer name

Want to generate PDF invoice by customer's name instead of the boring numbers? It's so easy - on this guide, I will show you how to do it:

Are you ready? Follow me.

How to generate Prestashop Invoice by Customer name

Before you do anything else, please make sure to backup your website / your file first. When you have done, let's go.

Step I - Modify function getFilename()

Open and edit function getFilename() in your-website/classes/pdf/HTMLTemplateInvoice.php by using your favourite editor.

Step II - Get the customer object : Find getFilename() function (line 500):

  public function getFilename()
      {
          $id_lang = Context::getContext()->language->id;
          $id_shop = (int)$this->order->id_shop;
          $format = '%1$s%2$06d';
  

Change it to:

  public function getFilename()
      {
          $id_lang = Context::getContext()->language->id;
          $id_shop = (int)$this->order->id_shop;
          $format = '%1$s%2$06d';
          $customer = new Customer((int)$this->order->id_customer);
  

Step III - Return with the name and the number

Look into this code:

  return sprintf(
              $format,
              Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop),
              $this->order_invoice->number,
              date('Y', strtotime($this->order_invoice->date_add))
          ).'.pdf';
  

Change it to:

  return sprintf(
              $format,
              Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop),
              $this->order_invoice->number,
              date('Y', strtotime($this->order_invoice->date_add))
          ).'_'.$customer->firstname.'_'.$customer->lastname.'.pdf';
  

Final - Enjoy your result

The generated invoice name will be IN_number_customername.pdf. For example IN000001_Natalia_Eva.pdf. We also released a new module called DocumenThemix to help you to customize and personalize the Prestashop Invoice template as well as Delivery Slip & Credit Slip. You should take a view on it and try for a while - it's powerful and easy to use.

Is it cool, huh? Don't forget our blog to find useful Prestashop tutorials.

Check the video to change it easier.

Have a nice weekend!

PrestaSEO AI++.

PrestaSEO AI module

PrestaSEO AI++ is a cutting-edge module designed to take your PrestaShop store’s SEO to the next level. Built with advanced automation and AI technology, it streamlines SEO tasks, making optimization easier and more effective.

Whether you're focused on improving local visibility or cleaning up your site's URL structure, PrestaSEO AI provides a comprehensive suite of features to enhance your store's performance.

Ultimo aggiornamento moduli!

Age Restriction - 18+ ⊙
Risolvere alcuni problemi di visualizzazione sui dispositivi mobili.


Newsletter Popup v3.2.2
Christmas Edition per incrementare le tue vendite.


Trusty v1.4.7 ⊙ 
Compatibile con PrestaShop 1.7 e PrestaShop 8.


PrestaSOO team
Tutto il necessario per guadagnarti da vivere facendo il lavoro che ami.

Scoprire


È un investimento saggio

I moduli Prestashop che abbiamo creato per primi per risolvere il problema del nostro business - un sito di e-commerce. Ciò significa che sono molto utili per un'azienda seria. Se apprezzi la tua proprietà web, questi moduli sono un investimento saggio.
Sarah Reeves, Sviluppatore di app @ PrestaSOO
Realizzato con a Parigi e Hanoi
PrestaSOO © 2024. Tutti i diritti riservati. // Politica sulla riservatezza Termini di servizio
''