Jump to content

How to disable notification mail sended after order change at BO


Recommended Posts

I think there is some confusion here as I would like to disable these messages as well.

The issue is if on the back office on an order details page, if products are manually added to the existing order, an auto email is sent to the customer. So if 10 product changes are made, the customer annoyingly receives 10 separate emails.

The status is not changed at all which is why as far as I can tell this issue cannot be toggled on the Orders / Statuses page.

Link to comment
Share on other sites

Great, thanks for pointing me in the right direction. While DEVs are here though, I think it is worth pointing out the default is not very good. It would make more sense to have a toggle of some sort to send out a general "your order has been updated" email on demand rather than an auto email after every small change made. It is not crazy to expect 2 changes to one order and the problem just gets worse for larger wholesale orders.

Link to comment
Share on other sites

  • 4 weeks later...

Thanks Tomerg3, it works!

 

For those with the same problem. I found the file in /public_html/controllers/admin and then AdminOrdersController.php.

On line 1746 I change the code to

public function sendChangedNotification(Order $order = null)
{
return false;

 if (is_null($order))
  $order = new Order(Tools::getValue('id_order'));

 $data = array(
  '{lastname}' => $order->getCustomer()->lastname,
  '{firstname}' => $order->getCustomer()->firstname,
  '{id_order}' => (int)$order->id,
  '{order_name}' => $order->getUniqReference()
 );

 Mail::Send(
  (int)$order->id_lang,
  'order_changed',
  Mail::l('Your order has been changed', $order->id_lang),
  $data,
  $order->getCustomer()->email,
  $order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
  null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop);


}

Edited by Christiaan_01 (see edit history)
  • Like 3
Link to comment
Share on other sites

  • 3 months later...
  • 7 months later...

Hi,

 

We have problem. When order is cancel Prestashop is sending out an email with "your order has changed status", despite the "Send an email to the customer when his/her order status has changed." is not ticked? 

Link to comment
Share on other sites

  • 9 months later...

Would be simpler and smarter maybe to add a configuration option

send email on all order changes -> on/off
and maybe if ON, let manager deside whether to send email or not, by some alert('would you like customer to be notified by email about thie order has changed (its recommended to do this if you now have finished editing the order)')

that way would be something i can live with (not queit as tottally stupid and brain dead)

I can make the code that should go inside function sendChangedNotification

who will make the code to control the ON/OFF ?

who will make the alert() and make sure some option is sent along like send_mail=1 if mail should be sent

 

we can sum it in a few files here

https://github.com/michaelhjulskov/smart_order_changed_email

Edited by michaelhjulskov (see edit history)
Link to comment
Share on other sites

okay first step has been taken to make an override

https://github.com/michaelhjulskov/smart_order_changed_email

 

we need to add PS_SEND_MAIL_ON_ORDER_CHANGE

to the BO administration and add it to the menu somewhere

who will continue that?

 

and wee need to make some js confirm('would you like customer to be notified by email about thie order has changed (its recommended to do this if you now have finished editing the order)')

if confirm is true, then add send_email to the request

Link to comment
Share on other sites

  • 4 months later...

IF you would like to disable the send mail for order edit you need to go to modules "Mail Alerts". 

The problem I see with this module which I believe is a bug, is that if you have multi store the "Off" feature only works on one of the stores. 

Link to comment
Share on other sites

  • 1 month later...

IF you would like to disable the send mail for order edit you need to go to modules "Mail Alerts". 

The problem I see with this module which I believe is a bug, is that if you have multi store the "Off" feature only works on one of the stores. 

 

Thanks BZZYBI, disabling the "Order edit" on "Customer notifications" area of the "mail alerts" plugin configuration should be the right solution.

Also on PS 1.6

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

IF you would like to disable the send mail for order edit you need to go to modules "Mail Alerts". 

The problem I see with this module which I believe is a bug, is that if you have multi store the "Off" feature only works on one of the stores. 

 

I am having the same issue, so I tried this in 1.6 but it didn't work.  It still keeps sending the emails after selecting NO to "Send a notification to the customer when an order is edited.."

Link to comment
Share on other sites

Thanks Tomerg3, it works!

 

For those with the same problem. I found the file in /public_html/controllers/admin and then AdminOrdersController.php.

On line 1746 I change the code to

public function sendChangedNotification(Order $order = null)
{
return false;

  if (is_null($order))
   $order = new Order(Tools::getValue('id_order'));

  $data = array(
   '{lastname}' => $order->getCustomer()->lastname,
   '{firstname}' => $order->getCustomer()->firstname,
   '{id_order}' => (int)$order->id,
   '{order_name}' => $order->getUniqReference()
  );

  Mail::Send(
   (int)$order->id_lang,
   'order_changed',
   Mail::l('Your order has been changed', $order->id_lang),
   $data,
   $order->getCustomer()->email,
   $order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
   null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop);
  

}

 

Thanks, this worked for me! :)

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

public function sendChangedNotification(Order $order = null)

{
if (is_null($order))
$order = new Order(Tools::getValue('id_order'));
 
$data = array(
'{lastname}' => $order->getCustomer()->lastname,
'{firstname}' => $order->getCustomer()->firstname,
'{id_order}' => (int)$order->id,
'{order_name}' => $order->getUniqReference()
);
 
Mail::Send(
(int)$order->id_lang,
'order_changed',
Mail::l('Your order has been changed', $order->id_lang),
$data,
$order->getCustomer()->email,
$order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop);
}
 
Hello,
 
what i should change in this function if i want to get mails in my mailbox but not in clients ?  
 
For example somebody changes old order and i got mail of that change 
Edited by ArturV (see edit history)
Link to comment
Share on other sites

  • 1 month later...

If this is still actual for someone, here are two bugs (see bellow for solution) in „Mail alerts“ module:

1. The module has setting Customer notifications: Order edit (Send a notification to the customer when an order is edited.).

But this setting is not saved after change.

2. The hook „hookActionOrderEdited“ is ignoring this setting too.

I have fix'ed the code and submitted a pull request in modules github repository. Hope it will be fixed soon.

 

As for now you can create an override. Steps:

1. Create file

/override/modules/mailalerts/mailalerts.php

2. Create override class with two overridden methods in this file. What was changed you can see here. Whole file:

<?php
if ( !defined( '_PS_VERSION_' ) ) {
	exit;
}

class MailAlertsOverride extends MailAlerts {

	/**
	 * Send a mail when an order is modified.
	 *
	 * @param array $params Hook params.
	 */
	public function hookActionOrderEdited($params)
	{

		if (
			!$this->order_edited ||
			empty($this->order_edited) ||
			!Configuration::get('MA_ORDER_EDIT')
		) {
			return;
		}

		$order = $params['order'];

		$data = array(
			'{lastname}' => $order->getCustomer()->lastname,
			'{firstname}' => $order->getCustomer()->firstname,
			'{id_order}' => (int)$order->id,
			'{order_name}' => $order->getUniqReference()
		);

		Mail::Send(
			(int)$order->id_lang,
			'order_changed',
			Mail::l('Your order has been changed', (int)$order->id_lang),
			$data,
			$order->getCustomer()->email,
			$order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
			null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop);
	}

	protected function postProcess()
	{
		$errors = array();

		if (Tools::isSubmit('submitMailAlert'))
		{
			if (
				!Configuration::updateValue('MA_CUSTOMER_QTY', (int)Tools::getValue('MA_CUSTOMER_QTY')) ||
				!Configuration::updateValue('MA_ORDER_EDIT', (int)Tools::getValue('MA_ORDER_EDIT'))
			) {
				$errors[] = $this->l('Cannot update settings');
			}
		}
		else if (Tools::isSubmit('submitMAMerchant'))
		{
			$emails = (string)Tools::getValue('MA_MERCHANT_MAILS');

			if (!$emails || empty($emails))
				$errors[] = $this->l('Please type one (or more) e-mail address');
			else
			{
				$emails = str_replace(',', self::__MA_MAIL_DELIMITOR__, $emails);
				$emails = explode(self::__MA_MAIL_DELIMITOR__, $emails);
				foreach ($emails as $k => $email)
				{
					$email = trim($email);
					if (!empty($email) && !Validate::isEmail($email))
					{
						$errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email);
						break;
					}
					elseif (!empty($email) && count($email) > 0)
						$emails[$k] = $email;
					else
						unset($emails[$k]);
				}

				$emails = implode(self::__MA_MAIL_DELIMITOR__, $emails);

				if (!Configuration::updateValue('MA_MERCHANT_MAILS', (string)$emails))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('MA_MERCHANT_ORDER')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('MA_MERCHANT_OOS')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('MA_MERCHANT_COVERAGE')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_ORDER_EDIT', (int)Tools::getValue('MA_ORDER_EDIT')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_RETURN_SLIP', (int)Tools::getValue('MA_RETURN_SLIP')))
					$errors[] = $this->l('Cannot update settings');
			}
		}

		if (count($errors) > 0)
			$this->html .= $this->displayError(implode('<br />', $errors));
		else
			$this->html .= $this->displayConfirmation($this->l('Settings updated successfully'));

		$this->init();
	}

}
  • Like 1
Link to comment
Share on other sites

  • 2 months later...

 

If this is still actual for someone, here are two bugs (see bellow for solution) in „Mail alerts“ module:

1. The module has setting Customer notifications: Order edit (Send a notification to the customer when an order is edited.).

But this setting is not saved after change.

2. The hook „hookActionOrderEdited“ is ignoring this setting too.

I have fix'ed the code and submitted a pull request in modules github repository. Hope it will be fixed soon.

 

As for now you can create an override. Steps:

1. Create file

/override/modules/mailalerts/mailalerts.php

2. Create override class with two overridden methods in this file. What was changed you can see here. Whole file:

<?php
if ( !defined( '_PS_VERSION_' ) ) {
	exit;
}

class MailAlertsOverride extends MailAlerts {

	/**
	 * Send a mail when an order is modified.
	 *
	 * @param array $params Hook params.
	 */
	public function hookActionOrderEdited($params)
	{

		if (
			!$this->order_edited ||
			empty($this->order_edited) ||
			!Configuration::get('MA_ORDER_EDIT')
		) {
			return;
		}

		$order = $params['order'];

		$data = array(
			'{lastname}' => $order->getCustomer()->lastname,
			'{firstname}' => $order->getCustomer()->firstname,
			'{id_order}' => (int)$order->id,
			'{order_name}' => $order->getUniqReference()
		);

		Mail::Send(
			(int)$order->id_lang,
			'order_changed',
			Mail::l('Your order has been changed', (int)$order->id_lang),
			$data,
			$order->getCustomer()->email,
			$order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
			null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop);
	}

	protected function postProcess()
	{
		$errors = array();

		if (Tools::isSubmit('submitMailAlert'))
		{
			if (
				!Configuration::updateValue('MA_CUSTOMER_QTY', (int)Tools::getValue('MA_CUSTOMER_QTY')) ||
				!Configuration::updateValue('MA_ORDER_EDIT', (int)Tools::getValue('MA_ORDER_EDIT'))
			) {
				$errors[] = $this->l('Cannot update settings');
			}
		}
		else if (Tools::isSubmit('submitMAMerchant'))
		{
			$emails = (string)Tools::getValue('MA_MERCHANT_MAILS');

			if (!$emails || empty($emails))
				$errors[] = $this->l('Please type one (or more) e-mail address');
			else
			{
				$emails = str_replace(',', self::__MA_MAIL_DELIMITOR__, $emails);
				$emails = explode(self::__MA_MAIL_DELIMITOR__, $emails);
				foreach ($emails as $k => $email)
				{
					$email = trim($email);
					if (!empty($email) && !Validate::isEmail($email))
					{
						$errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email);
						break;
					}
					elseif (!empty($email) && count($email) > 0)
						$emails[$k] = $email;
					else
						unset($emails[$k]);
				}

				$emails = implode(self::__MA_MAIL_DELIMITOR__, $emails);

				if (!Configuration::updateValue('MA_MERCHANT_MAILS', (string)$emails))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('MA_MERCHANT_ORDER')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('MA_MERCHANT_OOS')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('MA_MERCHANT_COVERAGE')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_ORDER_EDIT', (int)Tools::getValue('MA_ORDER_EDIT')))
					$errors[] = $this->l('Cannot update settings');
				elseif (!Configuration::updateGlobalValue('MA_RETURN_SLIP', (int)Tools::getValue('MA_RETURN_SLIP')))
					$errors[] = $this->l('Cannot update settings');
			}
		}

		if (count($errors) > 0)
			$this->html .= $this->displayError(implode('<br />', $errors));
		else
			$this->html .= $this->displayConfirmation($this->l('Settings updated successfully'));

		$this->init();
	}

}

I have made an override, but it's still sending this annoying e-mail :/

Link to comment
Share on other sites

I have made an override, but it's still sending this annoying e-mail :/

 

maybe because prestashop still uses original module file

remove class_index.php file to rebuild it with new paths to overides.

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...

I still didn't get it :-(

Which file I should be editing?

Where is the line which makes to send the email to the customer each time I make a change in BO ?

Can I just put this line between  /* ....*/   ? That should do the trick , no?

Link to comment
Share on other sites

Ok,

as above suggested , Delete or rename files called : order_changed.html and .txt

Important!  They are located in 2 places. 1) in your theme / mails /     2) in root / mails ......

You have to delete / edit both.  If you using default bootstrap.  If you just delete in one place, it will find a way to send the from 2nd place somehow.

Im not sure  if the function  calling up for this email "order_changed.html "  file which is not there anymore, if that is not going to make some mess , somewhere?

Some error stuff or something?

For the moment it works fine, but I would still prefer to find that line saying : send this "order _hanged.html" , and turn it off .

Link to comment
Share on other sites

On 28/11/2017 at 2:39 PM, Zeryk said:

Ok,

as above suggested , Delete or rename files called : order_changed.html and .txt

Important!  They are located in 2 places. 1) in your theme / mails /     2) in root / mails ......

You have to delete / edit both.  If you using default bootstrap.  If you just delete in one place, it will find a way to send the from 2nd place somehow.

Im not sure  if the function  calling up for this email "order_changed.html "  file which is not there anymore, if that is not going to make some mess , somewhere?

Some error stuff or something?

For the moment it works fine, but I would still prefer to find that line saying : send this "order _hanged.html" , and turn it off .

 

Hi there, this worked out for me (On 1.7):

On controllers\admin\AdminOrdersController.php, search for sendChangedNotification() function and just put a 

return false;

before anything else.

Edited by ggaston (see edit history)
Link to comment
Share on other sites

17 hours ago, ggaston said:

 

Hi there, this worked out for me (On 1.7):

On controllers\admin\AdminOrdersController.php, search for sendChangedNotification() function and just put a 

return false;

before anything else.

 

Where should I type  - false?

 

 

 }

    public function sendChangedNotification(Order $order = null)
    {
        if (is_null($order)) {
            $order = new Order(Tools::getValue('id_order'));
        }

        Hook::exec('actionOrderEdited', array('order' => $order));
    }

 

Link to comment
Share on other sites

I also having problems now with deleted email templates. I get warning sign that " order_changed.txt " is missing and doesn't allow me to save the changes:-(

but then change applies somehow...really confusing.

 

Changes are applied but I have to refresh the page all the time to see the difference.

So still have to find the turn OFF option.

Edited by Zeryk (see edit history)
Link to comment
Share on other sites

6 hours ago, Zeryk said:

public function sendChangedNotification(Order $order = null)
    {
        if (is_null($order)) {
            $order = new Order(Tools::getValue('id_order'));
        }

        Hook::exec('actionOrderEdited', array('order' => $order));
    }

 

This is how I did it:

public function sendChangedNotification(Order $order = null)
    {
        return false;
        if (is_null($order)) {
            $order = new Order(Tools::getValue('id_order'));
        }

        Hook::exec('actionOrderEdited', array('order' => $order));
    }

 

Link to comment
Share on other sites

3 hours ago, ggaston said:

 

This is how I did it:


public function sendChangedNotification(Order $order = null)
    {
        return false;
        if (is_null($order)) {
            $order = new Order(Tools::getValue('id_order'));
        }

        Hook::exec('actionOrderEdited', array('order' => $order));
    }

 

Good job! ..thanks a lot...works for me as well! :-)

Link to comment
Share on other sites

  • 1 year later...
On 12/1/2017 at 2:32 PM, Zeryk said:

Good job! ..thanks a lot...works for me as well! :-)

 

On 12/1/2017 at 11:16 AM, ggaston said:

 

This is how I did it:


public function sendChangedNotification(Order $order = null)
    {
        return false;
        if (is_null($order)) {
            $order = new Order(Tools::getValue('id_order'));
        }

        Hook::exec('actionOrderEdited', array('order' => $order));
    }

 

works also for me in PS 1.6.1.23. thanks 

Link to comment
Share on other sites

  • 1 year later...

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