andrex84 Posted April 8, 2011 Share Posted April 8, 2011 My client wanted the email address of the customer on the invoice in PrestaShop™ 1.4.0.17. It took me a while to figure it out since i'm not really a programmer but I found a solution and I hope it will help others too. In classes/customer.php add the following function which allows you to get customer data if you've got the ID. public function getCustomerByID($id) { $result = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_ .'customer` WHERE `active` = 1 AND `id_customer` = '.$id.' '); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result AS $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Then in classes/PDF.php AFTER: if (!empty($delivery_address->phone_mobile)) { $pdf->Ln(5); $pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L'); } ADD: $customerId = $order->id_customer; $customerObject = new Customer(); $customerObject->getCustomerByID($customerId); $pdf->Ln(5); $pdf->Cell($width, 10, $customerObject->email, 0, 'L'); Hope somebody finds this helpfull, and if anyone has any suggestions or modifications I'll be glad to know. 1 Link to comment Share on other sites More sharing options...
ross88online Posted April 10, 2011 Share Posted April 10, 2011 Thanks for this helpful post. Link to comment Share on other sites More sharing options...
Daan Tol Posted June 8, 2011 Share Posted June 8, 2011 Thanks for the great tip!Do you also know how to add the customer ID to the PDF ? Thanks in advance for the help! Link to comment Share on other sites More sharing options...
natalie123123 Posted September 23, 2011 Share Posted September 23, 2011 My client wanted the email address of the customer on the invoice in PrestaShop™ 1.4.0.17. It took me a while to figure it out since i'm not really a programmer but I found a solution and I hope it will help others too. In classes/customer.php add the following function which allows you to get customer data if you've got the ID. public function getCustomerByID($id) { $result = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_ .'customer` WHERE `active` = 1 AND `id_customer` = '.$id.' '); if (!$result) return false; $this->id = $result['id_customer']; foreach ($result AS $key => $value) if (key_exists($key, $this)) $this->{$key} = $value; return $this; } Then in classes/PDF.php AFTER: if (!empty($delivery_address->phone_mobile)) { $pdf->Ln(5); $pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L'); } ADD: $customerId = $order->id_customer; $customerObject = new Customer(); $customerObject->getCustomerByID($customerId); $pdf->Ln(5); $pdf->Cell($width, 10, $customerObject->email, 0, 'L'); Hope somebody finds this helpfull, and if anyone has any suggestions or modifications I'll be glad to know. Hi, I'm using Prestashop Version: 1.4.4.0 and I'm unable to locate the code you mention in pdf.php. Does anyone know how to add email addresses to invoices in this version of Prestashop? Thanks Link to comment Share on other sites More sharing options...
DaggaTora Posted October 10, 2011 Share Posted October 10, 2011 I have the same problem that natalie123123! Link to comment Share on other sites More sharing options...
Matthieu Brunet Posted October 17, 2011 Share Posted October 17, 2011 +1 Link to comment Share on other sites More sharing options...
Scott Z Posted January 4, 2012 Share Posted January 4, 2012 I took this approach in 1.4.2.5... 1. Add the classes/customer.php code as andrex84 suggested. 2. Modify classes/PDF.php as follows... AFTER public static function generateHeaderAddresses(&$pdf, $order, $addressType, $patternRules, $width) { ADD $customerId = $order->id_customer; $customerObject = new Customer(); $customerObject->getCustomerByID($customerId); FIND $pdf->MultiCell($width, 6.0, $addressType[$type]['displayed'], 0, 'L', 0); REPLACE WITH if ($type == 'invoice') { $pdf->MultiCell($width, 6.0, $addressType[$type]['displayed'] . $customerObject->email, 0, 'L', 0); } else { $pdf->MultiCell($width, 6.0, $addressType[$type]['displayed'], 0, 'L', 0); } Link to comment Share on other sites More sharing options...
Yuvarajan Posted May 9, 2012 Share Posted May 9, 2012 (edited) Thanks andrex84 Edited May 9, 2012 by Yuvarajan (see edit history) Link to comment Share on other sites More sharing options...
mendoza80 Posted July 26, 2012 Share Posted July 26, 2012 Thank you very very very much Scott (and Andrex84 of course) ! Link to comment Share on other sites More sharing options...
Rémy - @webdesignrr Posted November 5, 2013 Share Posted November 5, 2013 how about in prestashop 1.5 ? any idea ? Link to comment Share on other sites More sharing options...
tuk66 Posted November 5, 2013 Share Posted November 5, 2013 Look at Address Format for every country. This format is used in invoices. Link to comment Share on other sites More sharing options...
Doulas Akula Posted February 13, 2017 Share Posted February 13, 2017 For PS 1.6 To add an email - edit invoice.tpl in /pdf/ add this line within the template table where you want the email to appear <tr> <td colspan="12"> Email : {$customer_email} </td> </tr> The $customer_email is first initialised within HTMLTemplateInvoice.php file found in classes/pdf/ 'customer_email' => $customer->email, Find the function getContent() and look for this lines $tpls = array( 'customer_email' => $customer->email, 'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')), 'tax_tab' => $this->getTaxTabContent(), 'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')), 'note_tab' => $this->smarty->fetch($this->getTemplate('invoice.note-tab')), 'total_tab' => $this->smarty->fetch($this->getTemplate('invoice.total-tab')), 'shipping_tab' => $this->smarty->fetch($this->getTemplate('invoice.shipping-tab')), ); $this->smarty->assign($tpls); Notice 'customer_email' => $customer->email is the new addition. Link to comment Share on other sites More sharing options...
Recommended Posts