carplu Posted June 24, 2014 Share Posted June 24, 2014 Hi i use 1.6.06 for Trustpilot service i would like to add the emailaddress i received (with the customercodein it) just for the shipping email template no i added that mailaddress in modules>mail alerts and that works also but this adds every mail in the alerts to trustpilot best scenario would be that only when products are shipped this will go to their system but that requires me to add that emailaddress to bcc for shipping email template only Is this possible and how? Thank you so much Link to comment Share on other sites More sharing options...
cat1999 Posted October 14, 2014 Share Posted October 14, 2014 Hi, We are also looking for this solution. Can anyone tell us how to add a bcc email address to the order shipped email? Thanks Link to comment Share on other sites More sharing options...
magooattack Posted March 31, 2016 Share Posted March 31, 2016 Did you find any solution? I just need to know which file I should edit, in order to add the bcc email to the order shipped one. Anyone, please? Link to comment Share on other sites More sharing options...
Bonjovi67 Posted April 16, 2016 Share Posted April 16, 2016 Sorry to open this old topic again, but did you find any solutions ? I need the same function. Link to comment Share on other sites More sharing options...
Bonjovi67 Posted April 16, 2016 Share Posted April 16, 2016 Sorry to open this old topic again, but did you find any solutions ? I need the same function. I found this post https://www.prestashop.com/forums/topic/376904-how-to-email-copy-of-terms-and-conditions-for-each-shipped-order/ Would that be the right way to do it in Prestashop 1.6.1.4 or should it be done with a override ? I am new to prestashop, so i am not sure if it would be a propper way to do it with changing the core file mail.php. Link to comment Share on other sites More sharing options...
bellini13 Posted April 17, 2016 Share Posted April 17, 2016 I would suggest creating an override of the Mail class. Then you do not need to worry about future PS upgrades and losing your customization Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted June 22, 2017 Share Posted June 22, 2017 (edited) i try to make an ovverride to mail,.php adding a bcc email only if template is ="shipped" Don't know if i'm doing it right. <?php class Mail extends MailCore { 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) { // add trustpilot SFA 2.0 if($template == 'shipped') { $bcc->addBcc('*********@invite.trustpilot.com'); } } ?> is something that could work? Edited June 22, 2017 by ANGELO Vintage (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 23, 2017 Share Posted June 23, 2017 well $bcc variable is null by default, so this code would fail if that were the case. $bcc->addBcc('*********@invite.trustpilot.com'); The problem in PS v1.6.1.4 is that it is designed to only allow 1 email in the $bcc. So in order for your approach to work, you would have to do this instead $bcc = '*********@invite.trustpilot.com'; Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted June 23, 2017 Share Posted June 23, 2017 i modified as you suggested but i get error 500 every time i put the override Mail.php in the /override/classes folder Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted June 23, 2017 Share Posted June 23, 2017 anyway i chekced the Mail.php in 1.6.1.13 and seems is an array of emails /** * 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|array $to To email * @param string|array $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 int $id_shop Shop ID * @param string|array $bcc Bcc recipient(s) (email address) * @param string $reply_to Email address for setting the Reply-To header * @return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded. */ I've check better the documentation and i create this code but seems not working, It gives me back a 500 server error when the Send function is called (also during user registration for example). <?php class Mail extends MailCore { 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) { // add trustpilot SFA 2.0 if($template == 'shipped') { $bcc = '[email protected]'; } // send to customer 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); } ?> I place the Mail.php containing the code above in /override/classes folder, deleted the /cache/class_index.php file too. I've not find why it not work Link to comment Share on other sites More sharing options...
bellini13 Posted June 24, 2017 Share Posted June 24, 2017 fairly certain you stated PS v1.6.1.4 in your other thread. if you have an error 500, then you need to look at your php error log to determine why Link to comment Share on other sites More sharing options...
Scully Posted June 29, 2017 Share Posted June 29, 2017 (edited) Error 500 is most probably a syntax or logical error in your php. 1. Syntax check, for example here: http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/v5-3/syntax-check.php Result: the first paranthesis was not closed before the end of php at line 17. The correct syntax for adding a bcc directly would be: $message->addBcc($addr); So the additional part would be: if($template == 'shipped') { $message->addBcc('[email protected]'); } IMPORTANT: This part must be, after the object $message is created, which is at about line 185. If you put it in before, you also get an error. But the way with calling parent could also work as soon as you fix the syntax. $message = Swift_Message::newInstance(); Feedback is appreciated. Edited June 29, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted June 29, 2017 Share Posted June 29, 2017 Tipp: it's always helpful to use online php syntax checker. Modern editors have a lot of built-in-functionality to avoid syntax probs, but sometimes you get lost with lots of if-then-else or paranthesis problems like this one. Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted July 12, 2017 Share Posted July 12, 2017 hi Scully, thank you for yuo answer, i still using this version and seems working: <?php /* MODIFIED VERSION TO SUPPORT TRUSTPILOT SEND ON SHIPPED STATUS CHANGE */ class Mail extends MailCore { 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 == 'shipped') { $bcc = array('[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); } } you suggest anyway to change the line: if($template == 'shipped') { $bcc = array('[email protected]'); } with if($template == 'shipped'){ $message->addBcc('[email protected]'); } Is more correct? Ty Link to comment Share on other sites More sharing options...
Scully Posted July 12, 2017 Share Posted July 12, 2017 If it's working, it's good. My version has the advantage of NOT overwriting existing bcc if they exist. When you run your code and for example Mail Alerts or another Module has already set a BCC, it'l get lost with yours. Also note that my code must be inserted after the $message object hast been created. Link to comment Share on other sites More sharing options...
bellini13 Posted July 13, 2017 Share Posted July 13, 2017 Why would this be better? It would not even work, since $message is not available to you in this override code if($template == 'shipped'){ $message->addBcc('[email protected]'); } Link to comment Share on other sites More sharing options...
Scully Posted July 13, 2017 Share Posted July 13, 2017 @Bellini - i mentionned that $message must exist before angelo posted his code. Check the context ! Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted July 13, 2017 Share Posted July 13, 2017 if $bcc is an array we could use: array_push($bcc,'[email protected]'); could work to preserve the presence of other values in $bcc? Link to comment Share on other sites More sharing options...
bellini13 Posted July 14, 2017 Share Posted July 14, 2017 Seems to me you need to check the existing $bcc value first 1) Check if it is null. If it is null then just use your existing code 2) If it is not null, then check if it is an array. 2a) If it is an array, then you can just push your new email to the existing array. 2b) If it is not an array, then whatever called this function is doing it wrong, and you should convert $bcc to an array, and then add the emails to it. Link to comment Share on other sites More sharing options...
ANGELO Vintage Posted July 16, 2017 Share Posted July 16, 2017 Seems to me you need to check the existing $bcc value first 1) Check if it is null. If it is null then just use your existing code 2) If it is not null, then check if it is an array. 2a) If it is an array, then you can just push your new email to the existing array. 2b) If it is not an array, then whatever called this function is doing it wrong, and you should convert $bcc to an array, and then add the emails to it. ty i will follow your suggestion! Link to comment Share on other sites More sharing options...
Recommended Posts