Post by r3born » Sat May 12, 2012 1:15 am

Hello master ...

i want to custom email by order status. There are 3 custom email for it. order status Canceled, Complete, Pending. When admin send status with order status canceled, the email will send with format email content canceled email,,, same with complete and pending. those email will send accordance with the order status ...

Anyone can help me for this ???

Thank you master and friends here ... :) ...

regard
r3born ...

Newbie

Posts

Joined
Wed May 02, 2012 11:26 am

Post by Avvici » Sat May 12, 2012 2:14 am

In catalog/model/checkout/order.php you will use what is already given to you. In this function:

Code: Select all

public function confirm($order_id, $order_status_id, $comment = '', $notify = false) {
Just use $order_status_id to set up your conditional.

Example with using SWITCH to pull different email templates:
* You will change the numbers to match the different order status ID's. You can find those in PHPmyAdmin. In your database there is a table called "order_status". Notice that in each case you are pulling a different TPL as well. Just duplicate/rename mail/order.tpl over and over and add your own customizations to make each template unique. If you DON"T want the default information to show on all templates such as products orderes or total then you need to put all of these things within each CASE. Otherwise they apply to all. This example is for "adding" new information to the actual TPL's. Find this code

Code: Select all

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
				$html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
			} else {
				$html = $template->fetch('default/template/mail/order.tpl');
			} 
And replace it with this:

Code: Select all

switch($order_status_id){
			 case 1:
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
				$html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
			} else {
				$html = $template->fetch('default/template/mail/order.tpl');
			}
			break;
			
			 case 5:
			 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order2.tpl')) {
				$html = $template->fetch($this->config->get('config_template') . '/template/mail/order2.tpl');
			} else {
				$html = $template->fetch('default/template/mail/order2.tpl');
			}
			break;
			 case 3:
			 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order3.tpl')) {
				$html = $template->fetch($this->config->get('config_template') . '/template/mail/order3.tpl');
			} else {
				$html = $template->fetch('default/template/mail/order2.tpl');
			}
			break;
			
			//this executes if all other cases fail.
			default:
			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
				$html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
			} else {
				$html = $template->fetch('default/template/mail/order.tpl');
			}
			
			}

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by r3born » Sun May 13, 2012 11:08 am

thanks for your help ...

I have change code as you say above like this :D ....

switch($order_status_id){
case 1: // i change number 1 with order_status ID table in phpmyadmin.
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/pending.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/pending.tpl');
} else {
$html = $template->fetch('default/template/mail/pending.tpl');
}
break;

case 2: // i change number 2 with order_status ID table in phpmyadmin.
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/processing.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/processing.tpl');
} else {
$html = $template->fetch('default/template/mail/processing.tpl');
}
break;
case 5: // i change number 5 with order_status ID table in phpmyadmin.
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/complete.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/complete.tpl');
} else {
$html = $template->fetch('default/template/mail/complete.tpl');
}
break;

//this executes if all other cases fail.
default:
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
} else {
$html = $template->fetch('default/template/mail/order.tpl');
}

}


and admin area ... i go to sales - order - order history and change status order pending to process .. there are no send custom email processing.tpl .... I probably made ​​a mistake xD ...

still send email normal ...

"Order ID: 36
Date Ordered: 13/05/2012

Your order has been updated to the following status:
Processed

To view your order click on the link below:"

Newbie

Posts

Joined
Wed May 02, 2012 11:26 am

Post by r3born » Tue May 29, 2012 10:06 pm

Anyone can help me ???
still trouble with this email custom ...

Tq for your help ...

Newbie

Posts

Joined
Wed May 02, 2012 11:26 am

Post by mijomedia » Thu Dec 11, 2014 6:24 pm

I make a bump on this one, i also want to see this working, have been trying but it doesn't work

Webbutveckling, Sökmotoroptimering, E-handel, Mobilskal, Tillbehör för surfplattor och tillbehör för mobiler


User avatar
New member

Posts

Joined
Fri May 17, 2013 7:54 am
Who is online

Users browsing this forum: Semrush [Bot] and 25 guests