valeriopg Posted September 13, 2013 Share Posted September 13, 2013 Hiin my prestashop 1.5.4.1 I want to attach to the order confirmation email a custom pdf, with some customer data.In other words, I would like to generate a pdf for each order, save it in a folder and attach it to your order confirmation email.Where do I start?Tips? Link to comment Share on other sites More sharing options...
jgullstr Posted September 13, 2013 Share Posted September 13, 2013 (edited) Start by looking at the classes in PrestaShop's classes/pdf folder how PDF generation is handled. To add another attachment to your order confirmation e-mail, you will have to tinker either with the PaymentModule classes' validateOrder method, or the Mail::Send method. I recommend the latter due to reasons found here. The details you'd want to add to the pdf are most probably accessible through the current Context. The approach of inclusion would be similar, only that instead of adding a variable, you would have to add another attachment. For that, something along these lines should work: //Generate your PDF save it to an array of the form //$your_new_attachment = array('content' => $pdf_data, 'name' => 'filename.pdf', 'mime' => 'application/pdf'); if(is_array($file_attachment)){ $file_attachment[] = $your_new_attachment; }else if(!empty($file_attachment)){ $file_attachment = array($file_attachment, $your_new_attachment); }else{ $file_attachment = $your_new_attachment; } (The middle case would be the executing case, providing PDF invoices are enabled; the other ones are added to consider every possibility) Edited September 13, 2013 by jgullstr (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted September 17, 2013 Share Posted September 17, 2013 To add some specific data to the PDF you should override getContent() method in HTMLTemplateInvoiceCore class and modidy invoice.tpl template. 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