guybrush07 Posted February 20, 2013 Share Posted February 20, 2013 Hello, I want to auto-attach every invoice on Emails of accepted-paid orders of customers. Is this possible to happen ? I cant make it work till now ! any solution? I m using latest version of prestashop! Link to comment Share on other sites More sharing options...
guybrush07 Posted February 21, 2013 Author Share Posted February 21, 2013 (edited) OK yesterday i made some research and finally i attached invoices.pdf on mails but still cant make it work good! the problem now is that i see blank pdf file i added these lines on Mail.php if(strpos($template,'payment')) { $message->attach(new Swift_Message_Attachment(file_get_contents("/pdf-invoice.php?id_order=" . $template_vars['{id_order}']), "invoice.pdf", "application/pdf"));} Any way to fix blank mails? I think something is wrong with my "path" of generated pdfs. Result i m getting in payment mails is an attached blank file with name "invoice.pdf" 0kb Edited February 21, 2013 by guybrush07 (see edit history) 1 Link to comment Share on other sites More sharing options...
praneth Posted February 21, 2013 Share Posted February 21, 2013 I don't know if this is what you are looking for, but have you had a look at "Orders -> Statuses" in the Back Office? Link to comment Share on other sites More sharing options...
guybrush07 Posted February 21, 2013 Author Share Posted February 21, 2013 I already did that and it's enabled but that option in "status" is for front panel attachments and its working good! I want to attach invoice on a specific email template "payment" in every order! Link to comment Share on other sites More sharing options...
guybrush07 Posted February 22, 2013 Author Share Posted February 22, 2013 Any help plz? Link to comment Share on other sites More sharing options...
Whirly Posted May 13, 2013 Share Posted May 13, 2013 Did you solve your problem ? I face the same issue ! Link to comment Share on other sites More sharing options...
isoler Posted May 22, 2013 Share Posted May 22, 2013 Hello, I've solved this issue on Prestashop 1.4.9 You have to add the following on /classes/Mail.php on the function Send() just before the line with the comment: /* Send mail */ (in my file line 201): if (strpos($template, 'payment')){ $id_factura = $templateVars['{id_order}']; $orden = new Order($id_factura); $factura['content'] = PDF::invoice($orden, 'S'); $factura['name'] = $id_factura.'.pdf'; $factura['mime'] = 'application/pdf'; $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime'])); } This code attaches the invoice to 'Payment accepted' emails. If you want to attach the invoice to other emails just find the name of the template's mail and add it to the condition on the if statement. For example, if you want to attach the invoice too on the Shipped emails your code should look like this: if (strpos($template, 'payment' || strpos($template, 'shipped')){ $id_factura = $templateVars['{id_order}']; $orden = new Order($id_factura); $factura['content'] = PDF::invoice($orden, 'S'); $factura['name'] = $id_factura.'.pdf'; $factura['mime'] = 'application/pdf'; $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime'])); } I hope this help somebody, I googled around but I've found a lot of questions about this but no answer. Ivan. Link to comment Share on other sites More sharing options...
Yonkiedoodle Posted June 5, 2013 Share Posted June 5, 2013 Hello, I've solved this issue on Prestashop 1.4.9 You have to add the following on /classes/Mail.php on the function Send() just before the line with the comment: /* Send mail */ (in my file line 201): if (strpos($template, 'payment')){ $id_factura = $templateVars['{id_order}']; $orden = new Order($id_factura); $factura['content'] = PDF::invoice($orden, 'S'); $factura['name'] = $id_factura.'.pdf'; $factura['mime'] = 'application/pdf'; $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime'])); } This code attaches the invoice to 'Payment accepted' emails. If you want to attach the invoice to other emails just find the name of the template's mail and add it to the condition on the if statement. For example, if you want to attach the invoice too on the Shipped emails your code should look like this: if (strpos($template, 'payment' || strpos($template, 'shipped')){ $id_factura = $templateVars['{id_order}']; $orden = new Order($id_factura); $factura['content'] = PDF::invoice($orden, 'S'); $factura['name'] = $id_factura.'.pdf'; $factura['mime'] = 'application/pdf'; $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime'])); } I hope this help somebody, I googled around but I've found a lot of questions about this but no answer. Ivan. I have tried the above code on 1.5.4 but to no avail. I did notice that it uses $template_vars now instead of $templateVars though. Changed it but still no dice. Is there perhaps an update on this available somewhere? Some help would be greatly appreciated! Link to comment Share on other sites More sharing options...
soigroeg Posted August 18, 2013 Share Posted August 18, 2013 An Update to this would really be nice. Link to comment Share on other sites More sharing options...
Recommended Posts