bart81 Posted September 11, 2013 Share Posted September 11, 2013 In the new_order.html template there is a variable called {message}, which displays the message given by the customer. I want to display this message {message} also in the order_conf.html which is send to the customer. When I put this variable in the email template it doesn't display the message, just {message}, how can I fix this? Any help would be apprecitaed! Thanks in advance Kind regards Bart Link to comment Share on other sites More sharing options...
jgullstr Posted September 11, 2013 Share Posted September 11, 2013 (edited) Hello, The order_conf message is set up in the PaymentModule classes' ValidateOrder method, a 500+ row, text-book example of how not to do OOP. Since this method is crucial to PrestaShop's order workflow, overriding it would be a high-risk operation, as an upgrade most probably would break your shop. Editing it would be plausible, but then you'd have to make the same alterations over and over again when you update your shop. There is, however, a sneaky, somewhat clean way, to force variables into E-mail templates - overriding the Mail class. Try copying the following into a new file Mail.php into your override/classes folder: <?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) { if($template == 'order_conf' && empty($template_vars['{message}'])){ $context = Context::getContext(); if(!empty($context->cart->id)){ $message = Message::getMessageByCartId($context->cart->id); $template_vars['{message}'] = empty($message['message']) ? '' : $message['message']; } } return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop); } } Delete your cache/class_index.php file and try it out. You should be able to use the {message} flag.On a sidenote, I can think of countless use cases why a hook to add variables to mail templates be a great addition to a new PS version. Edited September 12, 2013 by jgullstr (see edit history) 4 Link to comment Share on other sites More sharing options...
bart81 Posted September 13, 2013 Author Share Posted September 13, 2013 jgullstr, You are a genius! Works like a charm, thanks a lot for helping me out!! Kind regards Bart Link to comment Share on other sites More sharing options...
ghomi Posted October 7, 2013 Share Posted October 7, 2013 Thanks for the tip! It's worked for me (don't forget delete cache/class_index.php file) (PS 1.5.4.1) Link to comment Share on other sites More sharing options...
Notesowo.pl Posted November 21, 2013 Share Posted November 21, 2013 It doesn't work for me. Just displaying {message} in email. Link to comment Share on other sites More sharing options...
y2001 Posted October 26, 2014 Share Posted October 26, 2014 Hi, try this: http://www.prestashop.com/forums/topic/372654-how-to-add-id-order-on-emailorder-conf/ it works fine for prestashop 1.6.0.x. It seems as the call of parent::send has one more parameter. regards 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