Jump to content

How to stop the "in_transit" mail from being sent to customer?


bjergmedia

Recommended Posts

Hi everyone,

 

Can anyone please tell me how to stop the "in_transit" mail from being sent to customers ?

 

We are using a module which generates a "tracking number" mail automatically when we tip in the tracking number at the order screen. So we don't want both mail to be sent.

 

Can I simply just delete the "in_transit" mail from the Folder on the server? or will this cause errors?

 

Looking forward to hear from you guys.

Link to comment
Share on other sites

Thanks for your quick answer Dh42 :)

 

It is OK that the "shipped" mail is being sent.

 

But The "in_transit" mail I can't find in the BackOffice? And it is being send out when I update the "tracking number" at the order screen?

Link to comment
Share on other sites

  • 11 months later...

I think deleting the mail templates will not work, at least in this case. If you search the prestashop core for "in_transit" and it only show up in the language class and in the AdminOrdersController.php at around line 480 (depending on your version i guess).

Seems like the mail being sent is pretty much hardcoded into the $order_carrier->update() action - if the mail cannot be sent (which would happen if you remove the template) the tracking number cannot be updated and just throws an error "An error occured while sending an email to the customer".

 

You will probably need to override the AdminOrdersController.php and copy the postProcess() function and then edit as follows PLEASE NOTE THIS IS NOT TESTED AT ALL!!!

if ($order_carrier->update())
{
  // Send mail to customer
  $customer = new Customer((int)$order->id_customer);
  $carrier = new Carrier((int)$order->id_carrier, $order->id_lang);
  if (!Validate::isLoadedObject($customer))
    throw new PrestaShopException('Can\'t load Customer object');
  if (!Validate::isLoadedObject($carrier))
    throw new PrestaShopException('Can\'t load Carrier object');
  $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, '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.');*/
}
  • Like 1
Link to comment
Share on other sites

  • 2 years later...

 

I think deleting the mail templates will not work, at least in this case. If you search the prestashop core for "in_transit" and it only show up in the language class and in the AdminOrdersController.php at around line 480 (depending on your version i guess).

Seems like the mail being sent is pretty much hardcoded into the $order_carrier->update() action - if the mail cannot be sent (which would happen if you remove the template) the tracking number cannot be updated and just throws an error "An error occured while sending an email to the customer".

 

You will probably need to override the AdminOrdersController.php and copy the postProcess() function and then edit as follows PLEASE NOTE THIS IS NOT TESTED AT ALL!!!

if ($order_carrier->update())
{
  // Send mail to customer
  $customer = new Customer((int)$order->id_customer);
  $carrier = new Carrier((int)$order->id_carrier, $order->id_lang);
  if (!Validate::isLoadedObject($customer))
    throw new PrestaShopException('Can\'t load Customer object');
  if (!Validate::isLoadedObject($carrier))
    throw new PrestaShopException('Can\'t load Carrier object');
  $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, '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.');*/
}

 

 

years later, same issue by me.

 

using 1.6.1.13 but the mentioned code isnt working by me, only generates a 500 error in BO.

tried several adjustements in this code but still doesnt work.

 

does anybody has a additional / further idea how to adjust the code to avoid the in_transit email to customers?

 

thanks in advance

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...