Roman0002 Posted October 23, 2014 Share Posted October 23, 2014 Hi guys, I would like to add order number({id_order}) to mail(order conf.) How do I do that? For answers and help thank you in advance Link to comment Share on other sites More sharing options...
cristic Posted October 23, 2014 Share Posted October 23, 2014 You have 2 ways of doing this: 1. Change directly in classes/PaymentModule.php. Search for // Send an e-mail to customer (one order = one email) if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) { $invoice = new Address($order->id_address_invoice); $delivery = new Address($order->id_address_delivery); $delivery_state = $delivery->id_state ? new State($delivery->id_state) : false; $invoice_state = $invoice->id_state ? new State($invoice->id_state) : false; $data = array( '{firstname}' => $this->context->customer->firstname, '{lastname}' => $this->context->customer->lastname, '{email}' => $this->context->customer->email, ..... and add {id_order} in the $data array: '{id_order}' => $order->id, 2. If you want to do this from within a module, you have to override Mail class, somethings like: 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) { $status = true; if (is_array($template_vars) && ( (isset($template_vars['{id_order}']) && (int)$template_vars['{id_order}'] > 0) || isset($template_vars['{order_name}']) && $template_vars['{order_name}'] != '') ){ //if we don't have an id_order but we have order_name - get the corresponding id_order if (!isset($template_vars['{id_order}']) || (int)$template_vars['{id_order}'] == 0) { $orderList = Db::getInstance (_PS_USE_SQL_SLAVE_)->ExecuteS (" SELECT `id_order` FROM `"._DB_PREFIX_."orders` WHERE `reference` = '" . $template_vars[ '{order_name}' ] . "'"); } else $orderList = array('id_order' => $template_vars['{id_order}']); //For each id_order, add id_order and send it foreach ($orderList as $order) { $order = new Order($order); if ($order->id) { $template_vars['{id_order}'] = $order->id; } $st = parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc); if ($status && !$st) $status = false; } return $status; } else { 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); } return true; } } The second choice will ensure that all emails sent that have an id_order - will add them to $template_vars array and can be used in email template. 1 Link to comment Share on other sites More sharing options...
YiannisK Posted September 15, 2016 Share Posted September 15, 2016 Unfortunately both methods do not work on PS 1.6. I try to find a solution a couple of weeks now but no luck Link to comment Share on other sites More sharing options...
rocky Posted September 17, 2016 Share Posted September 17, 2016 Find the data array on line 705 (in PrestaShop v1.6.1.7) of classes/PaymentModule.php: $data = array( '{firstname}' => $this->context->customer->firstname, and change it to: $data = array( '{order_id}' => (int)$order->id, '{firstname}' => $this->context->customer->firstname, Then you can use {order_id} in order_conf.html and order_conf.txt. Link to comment Share on other sites More sharing options...
YiannisK Posted September 20, 2016 Share Posted September 20, 2016 Sorry no luck I changed order_conf in both /mails & /themes/mytheme/mails I also changed new_order in both /modules/mailalerts and /themes/mytheme/modules/mailalerts Find the data array on line 705 (in PrestaShop v1.6.1.7) of classes/PaymentModule.php: $data = array( '{firstname}' => $this->context->customer->firstname, and change it to: $data = array( '{order_id}' => (int)$order->id, '{firstname}' => $this->context->customer->firstname, Then you can use {order_id} in order_conf.html and order_conf.txt. Link to comment Share on other sites More sharing options...
rocky Posted September 20, 2016 Share Posted September 20, 2016 That should have worked for order_conf.html and order_conf.txt, assuming it's being called by a payment module. If you've set it up to be called by an order status change, then the code above won't work, since you'd have to modify the data array in classes/OrderHistory.php instead. Link to comment Share on other sites More sharing options...
YiannisK Posted September 20, 2016 Share Posted September 20, 2016 Oh I see.. as payment I use codfee (Cash on delivery with fee) which is an alternative to COD. What can I do in this case? Thanks Link to comment Share on other sites More sharing options...
rocky Posted September 21, 2016 Share Posted September 21, 2016 I'm not familiar with that module. I would have expected it to use the PaymentModule class to send emails like the original Cash on Delivery module, but then my code above should have worked for you. Search the module to see if you can find where it's sending emails. Link to comment Share on other sites More sharing options...
Kerrex Posted October 1, 2016 Share Posted October 1, 2016 Hello, so is there actually any way to add variables to order_conf email? I'm trying to add bankwire details to template if a customer uses bankwire payment method.For the test I've added test tag {tagtest} => 'test' to data array but it doesn't work at all.I would be grateful for any help. Link to comment Share on other sites More sharing options...
YiannisK Posted November 1, 2016 Share Posted November 1, 2016 (edited) Not sure how to do that, but I know for sure that bankwire payment sends it's own email to customer with the bank details. Just make sure that the order status has "Send email to customer" checked. Hello, so is there actually any way to add variables to order_conf email? I'm trying to add bankwire details to template if a customer uses bankwire payment method.For the test I've added test tag {tagtest} => 'test' to data array but it doesn't work at all.I would be grateful for any help. Edited November 1, 2016 by joss54 (see edit history) Link to comment Share on other sites More sharing options...
kenoffice Posted January 23, 2020 Share Posted January 23, 2020 I have made 2 modifications in order to add the ID of order to emails subject, tested and worked for me (PS 1.6.1.18). I have posted already my solution on another topic, here: https://www.prestashop.com/forums/topic/926319-change-prestashop-email-subject-add-order-number/?tab=comments#comment-3192192 The ID of order is added now in 2 situations: 1. in subject of first email which customer receive after successful place an order; 2. on all emails subject sent when an order status have been changed and of course, PS was set up to notify the customer by email about status change. cheers ! 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