theboina Posted August 15, 2013 Share Posted August 15, 2013 (edited) When I send a "in transit" email to my customer, they receive the mail with {followup} without replace to Tracking URL. My AdminOrdersController.php: /controllers/admin/AdminOrdersController.php $templateVars = array( '{followup}' => str_replace('@', $order->shipping_number, $carrier->url), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{id_order}' => $order->id, '{shipping_number}' => $order->shipping_number, '{order_name}' => $order->getUniqReference() ); if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop)) { Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order)); Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token); } What's wrong? All other variables are replaced Ok. (firstname, lastname, etc) All other mails works popperly Data: My prestashop Version 5.3.1 Theme: Autumn Mail templates: mails/ (not in theme/autumn/mails Thx! Edited August 20, 2013 by theboina (see edit history) Link to comment Share on other sites More sharing options...
yaniby Posted August 19, 2013 Share Posted August 19, 2013 Hi Thebolina, After a whole day research and testing I have found the solutions (i had the same issue as you) problem: Prestashop allows you to create a custom order status and assigned the "in_transit" email template to it. which the code in /controllers/admin/AdminOrderController.php doesn't apply to and therefore applying any changes to that file will not affect the template when changing the order status to the one you've created. Solution: 1. open /classes/order/OrderHistory.php 2. add the following line $carrier = new Carrier($order->id_carrier, $order->id_lang); below $order = new Order($this->id_order); (line 364) so the first few lines of the "addwithemail" function look like this: public function addWithemail($autodate = true, $template_vars = false, Context $context = null) { if (!$context) $context = Context::getContext(); $order = new Order($this->id_order); $carrier = new Carrier($order->id_carrier, $order->id_lang); if (!$this->add($autodate)) return false; $result... 3. add the following line: $data['{followup}'] = str_replace('@', $order->shipping_number, $carrier->url); below: $data['{order_name}'] = $order->getUniqReference(); (line 397) so the following lines look like this: if ($result['module_name']) { $module = Module::getInstanceByName($result['module_name']); if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) $data = array_merge($data, $module->extra_mail_vars); } $data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false); $data['{order_name}'] = $order->getUniqReference(); $data['{followup}'] = str_replace('@', $order->shipping_number, $carrier->url); 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); } return true;... that's it.. 4 Link to comment Share on other sites More sharing options...
swsindonesia Posted August 20, 2013 Share Posted August 20, 2013 Hi theboina, does yaniby's solution works for you? Please take time to confirm, and edit your topic subject to be marked [sOLVED]. Link to comment Share on other sites More sharing options...
theboina Posted August 20, 2013 Author Share Posted August 20, 2013 Hi! Thanks a lot Yaniby!!! I'm out of home. I will try it this evening and I'll tell you. I was going crazy looking for a solution and could not find what could be the reason Thanks! Link to comment Share on other sites More sharing options...
theboina Posted August 20, 2013 Author Share Posted August 20, 2013 (edited) IT WORKS !!!!! Thank you very much yaniby. You just solved a problem that I have with him months without finding a solution ... (the number of lines change in my version 5.3.1, but the content is right!!) Thank you very much. I owe you a beer (or several). Edited August 20, 2013 by theboina (see edit history) Link to comment Share on other sites More sharing options...
letrof Posted October 23, 2013 Share Posted October 23, 2013 Hi Thebolina, After a whole day research and testing I have found the solutions (i had the same issue as you) problem: Prestashop allows you to create a custom order status and assigned the "in_transit" email template to it. which the code in /controllers/admin/AdminOrderController.php doesn't apply to and therefore applying any changes to that file will not affect the template when changing the order status to the one you've created. Solution: 1. open /classes/order/OrderHistory.php 2. add the following line $carrier = new Carrier($order->id_carrier, $order->id_lang); below $order = new Order($this->id_order); (line 364) so the first few lines of the "addwithemail" function look like this: public function addWithemail($autodate = true, $template_vars = false, Context $context = null) { if (!$context) $context = Context::getContext(); $order = new Order($this->id_order); $carrier = new Carrier($order->id_carrier, $order->id_lang); if (!$this->add($autodate)) return false; $result... 3. add the following line: $data['{followup}'] = str_replace('@', $order->shipping_number, $carrier->url); below: $data['{order_name}'] = $order->getUniqReference(); (line 397) so the following lines look like this: if ($result['module_name']) { $module = Module::getInstanceByName($result['module_name']); if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) $data = array_merge($data, $module->extra_mail_vars); } $data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false); $data['{order_name}'] = $order->getUniqReference(); $data['{followup}'] = str_replace('@', $order->shipping_number, $carrier->url); 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); } return true;... that's it.. Is this possible with 1.4 ? Link to comment Share on other sites More sharing options...
yaniby Posted October 23, 2013 Share Posted October 23, 2013 We've applied it to 1.5, the line no. might be off but it should work the same. Good Luck. Link to comment Share on other sites More sharing options...
letrof Posted October 23, 2013 Share Posted October 23, 2013 We've applied it to 1.5, the line no. might be off but it should work the same. Good Luck. Yeah but there is no /classes/order/OrderHistory.php in 1.4 version Link to comment Share on other sites More sharing options...
claybourg Posted November 15, 2013 Share Posted November 15, 2013 did not work for me 1.5.6 new install. The email is sending the tracking link but does not add the tracking number at the end of the link. Link to comment Share on other sites More sharing options...
vekia Posted November 16, 2013 Share Posted November 16, 2013 did not work for me 1.5.6 new install. The email is sending the tracking link but does not add the tracking number at the end of the link. problem solved? http://www.prestashop.com/forums/topic/287039-tracking-link-emailed-to-customer-not-displayed/?do=findComment&comment=1458560 Link to comment Share on other sites More sharing options...
kbytin Posted April 13, 2014 Share Posted April 13, 2014 problem solved? http://www.prestashop.com/forums/topic/287039-tracking-link-emailed-to-customer-not-displayed/?do=findComment&comment=1458560 Is it possible that only tracjing number will be sent without url? Our Delivery companies doesn't have this option (url + tracking number) so I want to modify e-mail, that will send links to delivery site and tracking number, so customer will follow the link and manualy copy/paste tracking number. And I'm om PS 1.6 Link to comment Share on other sites More sharing options...
janbru Posted April 24, 2015 Share Posted April 24, 2015 Worked for me too! I'm on 1.6.0.13. Link to comment Share on other sites More sharing options...
cvanavi Posted July 3, 2016 Share Posted July 3, 2016 I'm on 1.6.1.3 cloud version. {followup} is not working. It is sending a USPS.com link instead of link with tracking number. I've entered the tracking link with @ sign in place of tracking number in the carrier setup but it is not working. If I need to edit code, can you please direct me how to get there from the dashboard? I'm having a hard time finding tpl and php files. Not sure where to find them. Link to comment Share on other sites More sharing options...
Recommended Posts