Jump to content

How To : Add arrival date and arrival hour into confirmation email


Anonym

Recommended Posts

Hello everyone 

 

I would like to contribute to the community with a solution to how to add the arrival date and arrival hour info into confirmation email.

I searched on forums and did not found a solution so I tried and succeeded to do that myself.

 

First

Edit mailalerts.php file located under modules folder or your theme modules folder.

 Around line 357 add below $order_state = $params['orderStatus']; 

if ($invoice->id_state)
			$invoice_state = new State((int)$invoice->id_state);

		if (Product::getTaxCalculationMethod($customer->id) == PS_TAX_EXC)
			$total_products = $order->getTotalProductsWithoutTaxes();
		else
			$total_products = $order->getTotalProductsWithTaxes();

		$order_state = $params['orderStatus'];

the following code

$result = Db::getInstance()->getRow('
			SELECT da.`date`,da.`hour`
			FROM `'._DB_PREFIX_.'dateofarrival_cart` da			
			 WHERE da.`id_order` = '.(int)$order->id.' AND da.`is_appointed` = 1');

After that you have

	$template_vars = array(
			'{id_order}' => $order->id,
			'{firstname}' => $customer->firstname,
			'{lastname}' => $customer->lastname,
			'{email}' => $customer->email,

You will need to add the two new variables into the list. The code should look something like that

	$template_vars = array(
			'{order_delivery_date}' => $result['date'],
			'{order_delivery_time}' => $result['hour'],
			'{id_order}' => $order->id,
			'{firstname}' => $customer->firstname,
			'{lastname}' => $customer->lastname,
			'{email}' => $customer->email,
.....

Then you can use the two new variables in the mailalerts mails templates 

{order_delivery_date} and {order_delivery_time} .

 

One more thing to make sure it will work is to assure that the dateofarrival module is executed before mailaerts.

The reason of that is to have data inserted already into the dateofarrival modules at the time you are running the select query , otherwise you won't get any data into the select query.

 

To do that go into admin Modules Positions , check Display non-positionable hooks and under actionValidateOrder make sure that MailAlerts module is after the dateofarrival module.

 

That's all.

 

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