Jump to content

Customer message in customer confirmation email


Recommended Posts

Does anyone know how to go about feeding the customer message text in to the customer email? It already goes to the store owner in the email generated by the mailalerts module, but would be good to reassure the customer by echoing it back to them. This is using 1.3.2.3 with Onepage Checkout module.

Also conversely, the customized data information gets fed in to the customer email, but is not sent to the store owner. Anyone know where this data comes from and how to feed it in to the mailalerts email to the store owner?

Link to comment
Share on other sites

If anyone else wants this, the following appears to work:

 

1. In classes/PaymentModule.php, add the following just before the $data array (around line 380):

$customer_message = $order->getFirstMessage();

 

2. Same file, add the following to the $data array:

'{message}' => $customer_message

 

3. Place {message} wherever you want it in mails/en/order_conf.html and the .txt one too.

Edited by goosedesign (see edit history)
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...
  • 6 months later...
  • 10 months later...

Hi, i still have problem with {message} template var in Prestashop 1.6.

 

In classes/PaymentModule.php I added:

$customer_message = $order->getFirstMessage();
'{message}' => $customer_message

and in /themes/my_theme/mails/ i put {message} tag.

And it still doesn't work. I am getting mails with not parsed {message} tag.

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

  • 11 months later...
  • 2 months later...

Hi, i still have problem with {message} template var in Prestashop 1.6.

 

In classes/PaymentModule.php I added:

$customer_message = $order->getFirstMessage();
'{message}' => $customer_message

and in /themes/my_theme/mails/ i put {message} tag.

 

And it still doesn't work. I am getting mails with not parsed {message} tag.

This does not work for me neither. Also use Prestashop 1.6. Any idea?

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

try the following:

 

override the Paymentmodule.php as it follows:

 

1. add the following function:

	public function getAllMessages($id)
	{
		$messages = Db::getInstance()->executeS('
			SELECT `message`
			FROM `'._DB_PREFIX_.'message`
			WHERE `id_order` = '.(int)$id.'
			ORDER BY `id_message` ASC');
		$result = array();
		foreach ($messages as $message)
			$result[] = $message['message'];

		return implode('<br/>', $result);
	}

2. copy the entire function "public function validateOrder" from the original file PaymentModule.php and paste it in the override file, then look for the part $data = array(... and add the following line:

'{message}' => $this->getAllMessages($order->id),

now you can use {message} variable in your email template

  • Like 1
Link to comment
Share on other sites

  • 9 months later...
  • 2 years later...
  • 2 weeks later...

To add customer message to order confirmation e-mail you need to add to "/classes/PaymentModule.php" file just above the line where email variables are being assigned (around line ~580) something like this:

$mo = Message::getMessageByCartId((int) $this->context->cart->id);
$m = '';
if( !empty($mo) ) {
	$m = $mo['message'];
}

And then add this variable to $data array like:

$data = array(
	'{firstname}' => $this->context->customer->firstname,
	
	...,
	
	'{message}' => $m
);

Then you will be able to edit email translations in "International" -> "Translations" -> "Email translations" -> "Body" -> your theme -> your language -> Section "core emails" -> Type: "order_conf", and use {message} variable inside. Or you can edit email template in your files directly -> /themes/your_theme/mails/en/order_conf.html

After all this the best would be to copy code (only the function which was changed) from PaymentModule class and put it into override folder, to prevent it from being deleted during PS core upgrade.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi, 

i have problem on this customer message at prestashop 1.7.5 and when customer sends message on order confirmation, all of these scandic mark ÖÄäö are gone to html marks like below on admin panel side when looking customers messages.

&amp;auml;&amp;auml;kk&amp;ouml;sten

Any ideas where i can check this? all other message boxes works fine and are not breaking scandinavian characters. Only this order confirmation box (on srep 3 where select carrier) are breaking those special scandinavian characters. 

 

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...
Am 28.11.2020 um 1:35 PM schrieb rrataj:

To add customer message to order confirmation e-mail you need to add to "/classes/PaymentModule.php" file just above the line where email variables are being assigned (around line ~580) something like this:

$mo = Message::getMessageByCartId((int) $this->context->cart->id);
$m = '';
if( !empty($mo) ) {
	$m = $mo['message'];
}

And then add this variable to $data array like:

$data = array(
	'{firstname}' => $this->context->customer->firstname,
	
	...,
	
	'{message}' => $m
);

Then you will be able to edit email translations in "International" -> "Translations" -> "Email translations" -> "Body" -> your theme -> your language -> Section "core emails" -> Type: "order_conf", and use {message} variable inside. Or you can edit email template in your files directly -> /themes/your_theme/mails/en/order_conf.html

After all this the best would be to copy code (only the function which was changed) from PaymentModule class and put it into override folder, to prevent it from being deleted during PS core upgrade.

Does not work for PS 1.7.6.9, I only get {message} in mail if message is empty. Is there any solution to get for example "No customer message" oder something like that? 

 

Link to comment
Share on other sites

3 minutes ago, ***didi*** said:

Does not work for PS 1.7.6.9, I only get {message} in mail if message is empty. Is there any solution to get for example "No customer message" oder something like that? 

 

What if message is filled in? Do you have this content inside emails or always you get {message}? 

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