Eutanasio Posted August 2 Share Posted August 2 Hi, I'm trying to customize the PDF invoices generated by my Prestashop 1.7 store to include the total amount to be paid in words (in French), which is a legal requirement in my country. I've attempted to modify the following files but have not succeeded in getting the desired result. Here are the details of my approach: 1. Helper.php: Added a function to convert numbers to French words. class Helper extends HelperCore { public static function convert_number_to_words($num = false) { if (!is_numeric($num)) { return false; } $num = number_format($num, 2, '.', ''); list($integerPart, $fractionPart) = explode('.', $num); $words = self::convert_integer_to_words_fr($integerPart); $currency = 'dirhams'; $subunit = 'centimes'; $words .= ' ' . $currency; if ($fractionPart > 0) { $words .= ' et ' . self::convert_integer_to_words_fr($fractionPart) . ' ' . $subunit; } return ucfirst(trim($words)) . '.'; } private static function convert_integer_to_words_fr($num) { // Function implementation... } } 2. invoice.note-tab.tpl: Modified the template to include the total amount in words. {if isset($order_invoice->note) && $order_invoice->note} <tr> <td colspan="12" height="10"> </td> </tr> <tr> <td colspan="6" class="left"> <table id="note-tab" style="width: 100%"> <tr> <td class="grey">{l s='Note' d='Shop.Pdf' pdf='true'}</td> </tr> <tr> <td class="note">{$order_invoice->note|nl2br} {$total_paid_in_words} Dirhams</td> </tr> </table> </td> <td colspan="1"> </td> </tr> {/if} 3. HTMLTemplateInvoice.php: Overridden the `getContent` method to assign the total amount in words to the template. class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { public function getContent() { $order = new Order((int)$this->order->id); $total_paid = $order->total_paid; // Convert total paid to words in French $total_paid_in_words = Helper::convert_number_to_words($total_paid); // Assign the total paid in words to the template $this->smarty->assign(array( 'total_paid_in_words' => $total_paid_in_words, )); // Call the parent method to retain existing functionality return parent::getContent(); } } Despite these modifications, the total amount in words does not appear on the PDF invoices. Could anyone guide me on what might be going wrong or provide a solution to achieve this customization? Thank you in advance for your help! Link to comment Share on other sites More sharing options...
Nickz Posted August 2 Share Posted August 2 have you had the chance to read thru this: https://docs.prestashop-project.org/v.8-documentation/user-guide/selling/managing-orders/invoices Link to comment Share on other sites More sharing options...
Eutanasio Posted August 5 Author Share Posted August 5 solved https://www.prestashop.com/forums/topic/1089413-personalizar-la-factura-pdf-para-incluir-el-monto-total-en-letras/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now