Disable in_transit email



  • How do i disable the in_transit email so the customer do not receive the email everytime i insert a trackingnumber for an order?

    The problem was solved by following @wakabayashi 's suggestion by editing AdminOrdersController.php in /public_html/controllers/admin/.

    Change:

                            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', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$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.');
                            }
    

    To

                            Hook::exec('actionAdminOrdersTrackingNumberUpdate', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
    


  • You need to modify the if (@Mail::Send) a bit.

    if you want to get clean code answer, you shouldn’t add the code by screenshot…



  • Maybe this topic is intresting for you too: https://forum.thirtybees.com/topic/1381/brainstorming-handling-orders-in-bo/20 I am talking a bit about emails too.



  • Hello @wakabayashi

    What exactly would you suggest with the “if (1==1) {}” ?

    The code looks 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
                            )) {
    


  • Sorry forget my answer before…

    Change 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', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$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.');
                            }
    

    To:

    Hook::exec('actionAdminOrdersTrackingNumberUpdate', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
    

    I have tried this solution. So please test it out!



  • I get a 500 server error with that code when i go to Backoffice - Orders



  • Can you please show me the error or your code. I cant solve it otherwise.



  • It works now, thank you very much.

    I changed:

                            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', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$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.');
                            }
    

    To

                            Hook::exec('actionAdminOrdersTrackingNumberUpdate', ['order' => $order, 'customer' => $customer, 'carrier' => $carrier], null, false, true, false, $order->id_shop);
                                Tools::redirectAdmin(static::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
    


  • Ok nice! have you checked, if no email is going out?



  • Yes, it works perfect with no errors and no in_transit email.



  • Cool!



  • I move this topic no to the tipps section 😉


 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.