Wednesday, October 20, 2010

PrestaShop Tips - How to add email to invoce and delivery slip

In PrestaShop, the delivery slip and invoice are generated as PDF. Most store owner would like to have some kind of customization, like change format(layout) of delivery and invoice, or add some more information to invoice/delivery.

Here is a very simple example that add customer email address and order # to the delivery and invoice address contact part. This is very easy customization, what you have to do is:

Modify ./classes/PDF.php file as following.

Find following code block by search for !empty($delivery_address->phone_mobile.


if (!empty($delivery_address->phone_mobile))
{
$pdf->Ln(5);
$pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L');
}


Right after above code, add following code


$pdf->Ln(5);
$pdf->Cell($width, 10, $invoice_customer->email, 0, 'L');
$pdf->Ln(5);
$pdf->Cell($width, 10, self::l('ORDER #:') .sprintf('%06d', $order->id), 0, 'L');


You are ready to go.

Please note:
1. I have tested this on ver 1.3.1 (not sure for other versions)
2. This change will also affect invoice because they share the same content.

2 comments:

msk69 said...

Great, i was looking for a code to include the cart-id on the invoice. Do you know which code i should ude for that instead?

Thanks,

Marco

Alvin said...

Hi Marc,

I think you can use following code for cart id in PDF.php file

intval(self::$order->id_cart)

Hope this help