Jump to content
kandalf

How To Disable "in Transit" Emails From Being Sent?

Recommended Posts

I'm on Prestashop 1.6.1.2, and everytime I set a tracking number an emails is automatically sent, I want to stop this email and sent the tracking code on the "shipping" email.

 

I can't find any settings that enable me to deactivate the "in transit" emails.

 

Share this post


Link to post
Share on other sites

Disabling checkbox for "Processing in progress" status (Preparation template) will NOT help you.

 

To disable this In-Transit-email you should make some code editing (see screen).

Just comment this lines in /controllers/admin/AdminOrdersController.php file.

 

dMwY8IN.png

 

Just don't ask me why developers didn't make this option for backoffice. I wish i knew.

  • Like 1

Share this post


Link to post
Share on other sites

I was searching solution for this question and I found this topic. And after checking this clues I would like to describe what I had change.

 

I can't open this screenshot put by serdib.

I have Prestashop 1.6.0.14 and in this mentioned file /controllers/admin/AdminOrdersController.php just try to find this string: /* Update shipping number */

Below there are few lines of code responsible for sending email notification after setting tracking number. You shuold comment part of it. This lines starts in my verion from line 480.

Finaly it should look like this:

/*
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, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
    Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
/*
}
else
    $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
*/

Please be careful, because I didn't comment all this part of code. Un the middle there are still twa lines not commented.

 

I checked this and it works :)

 

What else? I prepared new email template and new order status - "prepared to send". In this email message I put info about tracking URL:

You can track your package using the following link: <a href="{followup}" style="color:#337ff1">{followup}</a>

Share this post


Link to post
Share on other sites

It is a bit different for PS 1.7.2+ versions.

As mentioned above you should change the file .../controllers/admin/AdminOrdersController.php
Here you should find next string (line 505 in my case):

if ($order_carrier->sendInTransitEmail($order))

as you see - there is new function sendInTransitEmail which btw is in the file .../classes/order/OrderCarrier.php
This function return True if mai (templates in_transit.html and/ or in_transit.txt) was sent successfully. To disable automatic sending of e-mail we should simply replace above mentioned line to described below:

// if ($order_carrier->sendInTransitEmail($order))
   if (True)


By commenting here the call of this function and set always True in the If clause - we simply bypass sending of this duplicated e-mail as using of shipped template is much more adequate and client-friendly.

To finalize - it would be good idea for PS team or somebody who is designing modules to create simple module, where admin would be able to switch off/ on all these a la default PS e-mails (I counted at least 5 of them, which are generating automatically and they sometimes are very irritating).

  • Thanks 2

Share this post


Link to post
Share on other sites
On 31/12/2017 at 1:42 AM, Vito said:

It is a bit different for PS 1.7.2+ versions.

As mentioned above you should change the file .../controllers/admin/AdminOrdersController.php
Here you should find next string (line 505 in my case):

if ($order_carrier->sendInTransitEmail($order))

as you see - there is new function sendInTransitEmail which btw is in the file .../classes/order/OrderCarrier.php
This function return True if mai (templates in_transit.html and/ or in_transit.txt) was sent successfully. To disable automatic sending of e-mail we should simply replace above mentioned line to described below:

// if ($order_carrier->sendInTransitEmail($order))
   if (True)


By commenting here the call of this function and set always True in the If clause - we simply bypass sending of this duplicated e-mail as using of shipped template is much more adequate and client-friendly.

To finalize - it would be good idea for PS team or somebody who is designing modules to create simple module, where admin would be able to switch off/ on all these a la default PS e-mails (I counted at least 5 of them, which are generating automatically and they sometimes are very irritating).

 

Hello!

When I do what you say, the "Orders" page throws me a 505.

 

EDIT: Now it's working so thx u so much :)

Thank you
Best regards

Edited by Raiderpoer (see edit history)

Share this post


Link to post
Share on other sites

Yes, you just have to deactivate above mentioned condition rule (by commenting "//") , and put instead of it new statement "If (true)" which means it will perform always - no magic. It has to work ;)

best regards, Vito

Share this post


Link to post
Share on other sites

Hello,

Unfortunately, this does not work from 1.6.1.20:

/*
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, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
    Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
/*
}
else
    $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
*/

It's blank page in orders:
Parse error: syntax error, unexpected 'else' (T_ELSE) in controllers/admin/AdminOrdersController.php on line 505

 

Problem solved:

/*  
	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, 'customer' => $customer, 'carrier' => $carrier), null, 		false, true, false, $order->id_shop);
	Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
/*	
	} else {
       $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
*/ 

This is correct code, attention to the brackets!

Edited by roman.b (see edit history)

Share this post


Link to post
Share on other sites

I tried in prestashop 1.6.1.23, but it doesn't work it gives me error 500 can someone help me? thank you

Share this post


Link to post
Share on other sites

Hi everyone.
Most of mail messages we can disable by admin panel.
So, just go to preferences->orders, and exactly there are statuses tab.
I'm sorry for image with polish language, but I hope, i helped in spite it.

prestasdcreen.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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