Jump to content

[SOLVED] Variable {followup} in email template is not replaced


Recommended Posts

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 by theboina (see edit history)

Share this post


Link to post
Share on other sites

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..

  • Like 4

Share this post


Link to post
Share on other sites

IT WORKS !!!!! :lol: :D

 

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 by theboina (see edit history)

Share this post


Link to post
Share on other sites

  • 2 months later...

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 ?

Share this post


Link to post
Share on other sites

  • 4 weeks later...
  • 4 months later...

 

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

Share this post


Link to post
Share on other sites

  • 1 year later...
  • 1 year later...

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.

Share this post


Link to post
Share on other sites

 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More