Prestashop How to use a different email template on tracking number update

Basically emails to be sent on order status update are configurable trough back office in Orders>Statuses.

Prestashop by default sends an email on tracking number update, however uses template „in_transit” and this is not configurable ( hardcoded ).

This template „in_transit” it’s used twice , at tracking no upgrade and on order set to status sent.

In order to change email template used, you have to add your template (both format .html ans . txt) in ALL languages folder which are set on your prestashop BO (or at least English, just have fr and en folder here) : root/mails/en

Email content can be translated in :Localization > Translations and in the section Modify Translations, under Type of translation choose Email templates translations and under Select your theme you can either choose to customize the core templates by selecting Core (no theme selected)

Once we have a new template defined and translated we need to assign template to code. Let’s suppose that new template it’s called ‘awb_allocated’.

We need to open AdminOrdersController.php and navigate to line above :

                       Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);

and change template to be used and title like below :

                    if (@Mail::Send((int)$order->id_lang, 'awb_allocated', Mail::l('It has been allocated an AWB number to your order', (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, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
                    } else {
                        $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');

Lasă un comentariu