umadevi.s Posted March 9, 2015 Share Posted March 9, 2015 Hi I have been searching in vain on how to attach the invoice pdf to the email generated when the product is shipped. I see a lot of suggestions on Prestashop1.4, but no working suggestions on how is it possible for 1.6 I would like the invoice to be sent every time the order status is set to "shipped" at the backoffice. I understand that I can have the customer download the invoice pdf from the order history, (based on what I configure in the order status) but my requirement is to ATTACH the pdf to the mail that is generated. Thanks Uma Link to comment Share on other sites More sharing options...
tuk66 Posted March 9, 2015 Share Posted March 9, 2015 First, your orders must go through the Payment accepted status. I think this is the only one status when the invoice is attached to the confirmation email. For me, it is still a little magic, but the default settings work well. Link to comment Share on other sites More sharing options...
umadevi.s Posted March 9, 2015 Author Share Posted March 9, 2015 Hi Thanks ! Yes I figured out this magic, or may be I am not understanding what you are suggesting.. 1. Yes when the Order status moves to "Payment Accepted" from the BO, I see the invoice pdf is attached to the mail. 2. I would like to attach the invoice pdf to the mail, when the order status moves to "Shipped" also. I do see a lot of suggestions on this forum on changes to mail.php and some more classes, none of those seem to work.. BTW, I use Prestashop 1.6 regards Uma Link to comment Share on other sites More sharing options...
koning Posted June 26, 2015 Share Posted June 26, 2015 Hi umadevi.s, Did you find a solution yet? I have the exact same problem; custom order status that needs a attached invoice when mailed to the customer. I also use PS 1.6. Regards, Jeroen. Link to comment Share on other sites More sharing options...
cleaner Posted July 28, 2015 Share Posted July 28, 2015 Hey Umadevi.S / Koning I'm also looking for this function to PS1.6 . Did you find any solution to this topic? Thanks, -C- Link to comment Share on other sites More sharing options...
CecileSabor Posted August 11, 2015 Share Posted August 11, 2015 Hello, I am looking for a solution of the same problem! Anyone?! Thanks!! Link to comment Share on other sites More sharing options...
alfons0 Posted October 7, 2015 Share Posted October 7, 2015 same here Link to comment Share on other sites More sharing options...
Shurek Posted February 1, 2017 Share Posted February 1, 2017 Same here.. it worked but now it stopped working Link to comment Share on other sites More sharing options...
Call_me_Dave Posted February 14, 2017 Share Posted February 14, 2017 Anyone please? Link to comment Share on other sites More sharing options...
misenec Posted September 5, 2017 Share Posted September 5, 2017 Backoffice, Orders => Order statuses => edit status where want add invoice pdf. Checkbox: Attach invoice PDF to email. 1 Link to comment Share on other sites More sharing options...
Scully Posted September 5, 2017 Share Posted September 5, 2017 That many questions and the solution is that simple. Order status allows quite some configuration, PDF invoice, delivery slip. Just look at the checkboxes available there. Link to comment Share on other sites More sharing options...
poletti.lucio Posted September 19, 2017 Share Posted September 19, 2017 Hi everyone, I've got an similar issue. When a new order is created, the customer gets the mail with the invoice attached (works well). But how can i manage to get me and another mail adress the same mail with the invoice & shippinglist? Just like a copy of the sent mail for the customer. I know, I can download them in the BO, but my Boss (the other mail adress) wants to have all orders, with invoice and shippinglist directly in the Outlook to manage everything... Does anyone have a idea? Thanks a lot for you help, best regards Peace Lui Link to comment Share on other sites More sharing options...
Scully Posted September 19, 2017 Share Posted September 19, 2017 You can simply override the class/Mail.php and use bcc as parameter. However this approach would send you mails from all kinds of stuff. Also customer welcome mail with their passwords (if password is part of the email template which is the case for prestashop default). Link to comment Share on other sites More sharing options...
misenec Posted September 19, 2017 Share Posted September 19, 2017 (edited) If have acces to FTP, can do somethink like this. (work fine for 1.6, i think 1.5, but idk 1.7) It's not 100% clean, because I'm not sure if any of the call function bcc already used. in shop_root/override/classes/ create if not exist: Mail.php insert this code: (bcc is hidden copy so normal recipient don't see it in header) class Mail extends MailCore { /** * Send Email * * @param int $id_lang Language ID of the email (to translate the template) * @param string $template Template: the name of template not be a var but a string ! * @param string $subject Subject of the email * @param string $template_vars Template variables for the email * @param string $to To email * @param string $to_name To name * @param string $from From email * @param string $from_name To email * @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files * @param bool $mode_smtp SMTP mode (deprecated) * @param string $template_path Template path * @param bool $die Die after error * @param string $bcc Bcc recipient * @return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded. */ public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) { if($template == 'new_order'){ //set the name of the template you want to send a copy $second_email = '[email protected]'; //email for copy send $bcc = $second_email; } return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to); } } Edited September 19, 2017 by misenec (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted September 19, 2017 Share Posted September 19, 2017 First of all, the template is named order_conf and not order_new. Second, using a variable just to hand it over to another variable doesn't make much sense. Better this way: if($template == 'order_conf'){ $bcc = "[email protected]"; } 1 Link to comment Share on other sites More sharing options...
poletti.lucio Posted September 20, 2017 Share Posted September 20, 2017 (edited) Hi guys, Thanks for the fast reply. I tried it and it worked, but the customer doesn't get an email now. The bcc mail gets all the mails now. Here is my code. Do i have to place the code at another place? class Mail extends MailCore { /* * module: gwadvancedinvoice * date: 2017-06-12 15:49:45 * version: 1.2.0 */ public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) { if(Module::isInstalled('gwadvancedinvoice') && Module::isEnabled('gwadvancedinvoice')){ if (!empty($file_attachment)) { if ($template === 'order_conf' || $template === 'payment') { if (isset($file_attachment['invoice']) && isset($file_attachment['invoice']['name'])) { $invoiceObj = Module::getInstanceByName('gwadvancedinvoice'); $id_order_invoice = (int)Tools::substr($file_attachment['invoice']['name'], Tools::strlen($file_attachment['invoice']['name'])-10,6); if($id_order_invoice > 0){ $OrderInvoiceObj = new OrderInvoice((int)$id_order_invoice); if(Validate::isLoadedObject($OrderInvoiceObj)){ $file_attachment['invoice']['name'] = $invoiceObj->formatNumber('I',$OrderInvoiceObj->number,$OrderInvoiceObj). '.pdf'; if (isset($file_attachment['delivery']) && isset($file_attachment['delivery']['name'])) { $file_attachment['delivery']['name'] = $invoiceObj->formatNumber('D',$OrderInvoiceObj->delivery_number,$OrderInvoiceObj). '.pdf'; } } } } } } } if($template == 'order_conf'){ $bcc = "[email protected]"; } return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to); } } Sorry, I just received the message (I am the customer) but 10 minutes later. Was it maybee just an server connection issue? So the code works thanks again guys. But it takes around 10 minutes until the customer gets the mail...(tried it again) Any ideas? Thanks and best regards Lui Edited September 20, 2017 by poletti.lucio (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted September 20, 2017 Share Posted September 20, 2017 If you use SMTP some kind of delays are not unusual. Using PHP mail has the advantage of not relaying on an external machine and hence is usually faster. Link to comment Share on other sites More sharing options...
poletti.lucio Posted September 20, 2017 Share Posted September 20, 2017 Okay, thanks for the advice. In the backoffice I logically use PHP for the mail process. Is there something I could do to speed up things? thanks and best regards Lucio Link to comment Share on other sites More sharing options...
Scully Posted September 20, 2017 Share Posted September 20, 2017 Nothing that I would be aware of. If you consider this as problem you could start debugging Mail.php. For example log to the datatbase at the beginning with a timestamp and log at the end of the send:: function again to compare if the dalay occures there. But my guess is rather than the dalay ise caused outside of prestashop. So it would be more related to a hosting issue. Link to comment Share on other sites More sharing options...
poletti.lucio Posted September 20, 2017 Share Posted September 20, 2017 Alright, thanks a lot Scully. I will test it through the day. best regards Lucio 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