pave Posted November 3, 2012 Share Posted November 3, 2012 Hi, I have 1.5.0.17 (and can not easily upgrade to 1.5.2) and I am not able to attach invoice to mail, which confirms payment (nor to any other mail) to customer. I am not sure, if it is an error or just bad settings, but I have set "send mail to customer" for appropriate statuses and I do not know about any other settings related with it. Are there any "rules", what and how must be something set to attach invoice? I have "advanced stock management" switched on, language Czech (but switch to English did not help). I have changed fonts for PDF generation, but PDF invoice generation in backend office works fine, so it is not the reason of the problem. I use bankwire and cashondelivery payments, both have the same problem. Has somebody a tip? For example - mail "Shipped" is send only if the tracking number is filled (and it is not described in 1.5 manual). Is there something similar with invoices? Link to comment Share on other sites More sharing options...
peranders Posted November 3, 2012 Share Posted November 3, 2012 Have you checked Orders Statuses Link to comment Share on other sites More sharing options...
pave Posted November 5, 2012 Author Share Posted November 5, 2012 What do you mean? In Statuses is possible to set on/off mailing, but about attachement(s) I found nothing. Link to comment Share on other sites More sharing options...
mvanrijnen Posted November 27, 2012 Share Posted November 27, 2012 (edited) i would like a solution to this problem too. When someones chooses Bankwire payment, and confirms his order he get's the right email. But when in the BackOfffice the state of the order is changend to PaymentAccepted, the customer should get an invoice with his email. I'v been trying but without luck so far --- found it ---- bit strange but it works. just check the checkmark for Allow customer ..... PDF ...... Edited November 27, 2012 by mvanrijnen (see edit history) Link to comment Share on other sites More sharing options...
MSkovmose Posted December 1, 2012 Share Posted December 1, 2012 i would like a solution to this problem too. When someones chooses Bankwire payment, and confirms his order he get's the right email. But when in the BackOfffice the state of the order is changend to PaymentAccepted, the customer should get an invoice with his email. I'v been trying but without luck so far --- found it ---- bit strange but it works. just check the checkmark for Allow customer ..... PDF ...... Yes the user can then see his invoice in his account on the website. But it doesnt mail the invoice as an attachment to the user alone with the order confirmation. At least not in my shop. So I would like to know how this is solved as well, so my customers can get the invoice as an attachment. Link to comment Share on other sites More sharing options...
mister006 Posted February 14, 2013 Share Posted February 14, 2013 (edited) Hi guys, I have the same problem: I can see the invoices in the back office of the shop, but the pdf is not attached to the order confirmation mails which are sent to customers. I have checked the status page, send invoice is marked, but It doesn't matter. Also with other statusses like Payment Accepted, an email is sent to the customer but no invoice is attached, while the option is marked in the back-office. I tried all configuration options in the back office, but no change: The invoice-pdf is not attached to any mail. The normal mailing works perfect. Can you please help me with this? Thanks! I am using PrestaShop 1.5.3.1 by the way. Edited February 14, 2013 by mister006 (see edit history) Link to comment Share on other sites More sharing options...
guybrush07 Posted February 22, 2013 Share Posted February 22, 2013 Hello, same problem here! With that code i can attach the invoice on mail after order is paid>>>>i mean payment accepted 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"));} The problem now is that i m attaching a blank mail! 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 Link to comment Share on other sites More sharing options...
pr11t Posted February 25, 2013 Share Posted February 25, 2013 I am experiencing the same problem, I have tried many "hacks", but I haven't been able to get it to work. Link to comment Share on other sites More sharing options...
guybrush07 Posted March 6, 2013 Share Posted March 6, 2013 Any update here? Link to comment Share on other sites More sharing options...
mehnihma Posted March 13, 2013 Share Posted March 13, 2013 Anyone solved this? Link to comment Share on other sites More sharing options...
Whirly Posted May 13, 2013 Share Posted May 13, 2013 Dans paymentModule.php j'ai trouvé ça. Est- ce qu'on ne peut pas mixer tout ça ? // Join PDF invoice if ((int)(Configuration::get('PS_INVOICE')) AND Validate::isLoadedObject($orderStatus) AND $orderStatus->invoice AND $order->invoice_number) { $fileAttachment['content'] = PDF::invoice($order, 'S'); $fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)($order->id_lang)).sprintf('%06d', $order->invoice_number).'.pdf'; $fileAttachment['mime'] = 'application/pdf'; } else $fileAttachment = NULL; if (Validate::isEmail($customer->email)) Mail::Send((int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment); Link to comment Share on other sites More sharing options...
benjamin utterback Posted May 13, 2013 Share Posted May 13, 2013 Dans paymentModule.php j'ai trouvé ça. Est- ce qu'on ne peut pas mixer tout ça ? Hi Whirly, could you please translate what you have said in English. This way the English forum can better understand. 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. 2 Link to comment Share on other sites More sharing options...
gsoffer Posted May 23, 2013 Share Posted May 23, 2013 I tried it on the new version 1.5.4.1 and it didn't work. Anyone for suggestions? Link to comment Share on other sites More sharing options...
Yonkiedoodle Posted June 6, 2013 Share Posted June 6, 2013 (edited) I am on 1.5.4 and trying to get this working too but no luck I did find this thread though, but still cant get it to work... http://www.prestashop.com/forums/topic/75045-attachments-to-e-mails/page__st__20 Edited June 6, 2013 by Yonkiedoodle (see edit history) Link to comment Share on other sites More sharing options...
isoler Posted June 6, 2013 Share Posted June 6, 2013 I am on 1.5.4 and trying to get this working too but no luck I did find this thread though, but still cant get it to work... http://www.prestasho...ls/page__st__20 Upload your /classes/Mail.php file and I will take a look at it. Link to comment Share on other sites More sharing options...
Yonkiedoodle Posted June 6, 2013 Share Posted June 6, 2013 Upload your /classes/Mail.php file and I will take a look at it. Here you go. Ok I got it to attach the pdf now, but the file seems to be always corrupt. So I think I'm almost there!! Mail.php Link to comment Share on other sites More sharing options...
Dognose Posted June 14, 2013 Share Posted June 14, 2013 Hi isoler, i have read your instruction and include your code. It runs perfect. It's now possible. Realy nice! But I have installed the module: M4 PDF Extensions v1.7.1 This module generate my invoices with a selfmade template. In the attachement is actually the "original/old" invoice. Is it possible to attache the new invoice from M4? If you need more details, please say me... Thank you for answere. Cheers Link to comment Share on other sites More sharing options...
mehnihma Posted June 14, 2013 Share Posted June 14, 2013 Did you make it work on 1.5? Link to comment Share on other sites More sharing options...
Dognose Posted June 14, 2013 Share Posted June 14, 2013 No, I work with 1.4.7 Link to comment Share on other sites More sharing options...
mehnihma Posted June 14, 2013 Share Posted June 14, 2013 Anyone made it work with 1.5? Link to comment Share on other sites More sharing options...
Dognose Posted June 14, 2013 Share Posted June 14, 2013 I have found for a few hours this link: http://btcdev.net/en/mail-attachment-order It not so expensive.. Maybe it works.. Link to comment Share on other sites More sharing options...
isoler Posted June 14, 2013 Share Posted June 14, 2013 Hi isoler, i have read your instruction and include your code. It runs perfect. It's now possible. Realy nice! But I have installed the module: M4 PDF Extensions v1.7.1 This module generate my invoices with a selfmade template. In the attachement is actually the "original/old" invoice. Is it possible to attache the new invoice from M4? If you need more details, please say me... Thank you for answere. Cheers Hi Dognose, If you want to change the invoice that it's sending now for the one that generates the module you have told, you have to change this line at the code that I've provided: $factura['content'] = PDF::invoice($orden, 'S'); In this line we are calling the function invoice() that is defined in the file /classes/PDF.php so we are generating an invoice Prestashop's like. If you want to send the invoice that your module generates we have to call the function that do this in the file usually located at /modules/yourmodule/yourmodule.php. I didn't worked with that module so I don't know wich is that function. You have to look at the *.php file of the module and search for the function that generates the invoice, if you need help, upload the file and I will take a look at that and I'll try to guide you Link to comment Share on other sites More sharing options...
Dognose Posted June 14, 2013 Share Posted June 14, 2013 Hi, thank you for fast answere. I understand what you mean. It sounds god. I just do me hard to find the right file in this module. I hope it's the right. I have send you parallel a PN with a link from me, to download the complete module. Thank you for looking. Cheers pdf.php Link to comment Share on other sites More sharing options...
isoler Posted June 14, 2013 Share Posted June 14, 2013 (edited) Hi, thank you for fast answere. I understand what you mean. It sounds god. I just do me hard to find the right file in this module. I hope it's the right. I have send you parallel a PN with a link from me, to download the complete module. Thank you for looking. Cheers Hi Dognose, Replace the whole code that I've told you for this one on the file /classes/Mail.php: if (strpos($template, 'payment')){ require_once(dirname(__FILE__).'/../modules/m4pdf/M4OrderDetail.php'); $id_factura = $templateVars['{id_order}']; $generator = new M4OrderDetail(); $invoice_content = $generator->generatePDF('invoice'.sprintf('%06d', $id_factura).'.pdf', 'S', Configuration::get('M4TPL_PDF_INVOICE')); $factura['content'] = $invoice_content; $factura['name'] = $id_factura.'.pdf'; $factura['mime'] = 'application/pdf'; $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime'])); } Test it and told me if it worked Edited June 14, 2013 by isoler (see edit history) Link to comment Share on other sites More sharing options...
Dognose Posted June 14, 2013 Share Posted June 14, 2013 I have tested, but unfortunately it did not work. It's loading very long after change status. The result (after ~30sec.) is a blank screen. And it will not send any more email. Link to comment Share on other sites More sharing options...
Yonkiedoodle Posted June 15, 2013 Share Posted June 15, 2013 Yea, I am using 1.5.4.1 and the same thing happens. Blank screen and no email sent Link to comment Share on other sites More sharing options...
Dognose Posted June 18, 2013 Share Posted June 18, 2013 Hi isoler, the module running now. I have overlooked a simple setting in M4 module. Only your first one code is right! Thank's for support and looking Cheers Link to comment Share on other sites More sharing options...
pepitofgg Posted September 19, 2013 Share Posted September 19, 2013 (edited) Anyone made it work with 1.5? I have found that solution for PS 1.5.5: https://github.com/PrestaShop/PrestaShop/commit/9ff0d601589fdf791a8bd895de187bb45eb7939f It works in my PS 1.5.4.1 making theese changes in classes\order\OrderHistory.php file: Arround line 370, replace this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name` by this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state` And arround line 403, replace this: if (Validate::isLoadedObject($order)) Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'], null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop); by this: if (Validate::isLoadedObject($order)) { // Join PDF invoice if order state is "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else $file_attachement = null; Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop); } I guess it will not be difficult to adapt these changes to other sub-versions of PS 1.5. Edited September 19, 2013 by pepitofgg (see edit history) 3 Link to comment Share on other sites More sharing options...
mouse1 Posted October 17, 2013 Share Posted October 17, 2013 (edited) Thank you pepitofgg, this seems to be working very well on my 1.5.4.0 . Edited September 18, 2018 by mouse1 (see edit history) Link to comment Share on other sites More sharing options...
hosteleriex Posted March 17, 2014 Share Posted March 17, 2014 I have found that solution for PS 1.5.5: https://github.com/PrestaShop/PrestaShop/commit/9ff0d601589fdf791a8bd895de187bb45eb7939f It works in my PS 1.5.4.1 making theese changes in classes\order\OrderHistory.php file: Arround line 370, replace this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name` by this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state` And arround line 403, replace this: if (Validate::isLoadedObject($order)) Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'], null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop); by this: if (Validate::isLoadedObject($order)) { // Join PDF invoice if order state is "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else $file_attachement = null; Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop); } I guess it will not be difficult to adapt these changes to other sub-versions of PS 1.5. These changes are already in 1.5.6.1 but not works for me Link to comment Share on other sites More sharing options...
Zebx Posted April 30, 2014 Share Posted April 30, 2014 Hi, The addWithemail function in OrderHistory.php is limiting the invoice annexing to the order state "payment accepted". So in case you changed the status for invoice creation, you have to modify the following code : // Join PDF invoice if order state is "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) Example for status "shipped" (ID = 4) : // Join PDF invoice if order state is "shipped" if ((int)$result['id_order_state'] === 4 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) 1 Link to comment Share on other sites More sharing options...
pixelofficer Posted August 13, 2015 Share Posted August 13, 2015 (edited) Bloody hell, why there is checkmark for sending PDF invoice or all statuses - even custom ones - when there is no way to attach invoice to other status than payment and bankwire awaiting payment without PHP hack? I'm not good at PHP - but if you change the line above to if (((int)$result['id_order_state'] === 2 || (int)$result['id_order_state'] === 16) && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) You can enable sending PDF invoice for multiple statuses (in this case - 2 and 16 - where 16 is my manually created status) It wors in 1.6.0.14 ...But I hope that one day develeopers will fix it.... But may you can simply throw away condition about order state - and it will be up to you and checkboxes Edited August 13, 2015 by pixelofficer (see edit history) Link to comment Share on other sites More sharing options...
kNife77 Posted February 24, 2016 Share Posted February 24, 2016 Hi, Simple hack for 1.6.0.9 Go to Location -> translations -> translate email template core translations ! and select language. Then, go to shipping template, you'll find edit html where you have source code : copy all that code and paste it to payment email template ! Then, go to Orders->status->payment and check mark as shipped, mark as paid etc. And now when you have a new order, just change the status to payment accepted and they will recive the shipped email template and the pdf invoice. Do not forget to edit the loiality module if installed ! Change the loiality points validate to payment status instead of shipped. Link to comment Share on other sites More sharing options...
Recommended Posts