After adding a "Product Review Email Notice"
http://forum.opencart.com/viewtopic.php ... 647#p33580
I got inspired to take a try at modifying the conformation email (For the Customer and Admin) so that they would be sent as formated HTML .. See Sample.

After poking around in the code i found that Opencart's Mail class had a HTML option.
So after a test to see if I could call to it from the "order.php" file was successful, I set out to reprogramming the file for HTML formated e-mail with store logo.
This method may not be exactly 'mvc' but it worked for me and I hope someone else can get some good out of it.
Save a copy of this code someplace on your computer because I am sure you will have to make the changes again if the order.php gets changed in a future update.
Here is what you need to know:
- FIRST! If any of these instruction sound foreign to you or if you don't know what a FTP program is or how to find files. Don't try it!
- This is for OpenCart 1.3.2 un-altered order.php -- for any other version, you are on your own.
- The file you need to edit is catalog/model/checkout/order.php
- BACK UP THIS FILE !!!
- Go to line 64 or just after the line that starts "$order_download_query..."
- DELETE EVERYTHING below line 64.
- Replace it with the script below.
- Make changes to the lines marked as /*Logo*/ so that the paths point to your site and your logo file
- Save!
Code: Select all
/*Get user info*/ $addressEmail= $this->customer->getAddress($this->session->data['shipping_address_id']);
// Mail to Custumer -----------------------------------------------------------
/* message start ->*/ $message =""
/*Logo*/ ."<div style='text-align:center'><a href='http://YOURSITE.com'><img src='http://YOURSITE.com/image/logo.png'align='center'/></a></div>"
/*Order */ ."<h2>".$language->get('mail_new_order_order')."<span style='color:red;'>".$order_id."</span></h2>"
."<div style='color:blue;text-align:center'>".sprintf($language->get('mail_new_order_greeting'),$this->config->get('config_store'))."</div><br>"
."<table border 1 cellpadding='3' cellspacing='0' width='250' bgcolor='#e6edff'>"
.$addressEmail[firstname]." ".$addressEmail[lastname]."<br>"
.$addressEmail[address_1]." - ".$addressEmail[address_2]."<br>"
.$addressEmail[city]." ".$addressEmail[zone]." ".$addressEmail[postcode]."<br>"
.$addressEmail[country]."</table>"
/*date/status*/ ."<table border='0' cellpadding='3' cellspacing='0' width='500'>"."<tr>"
."<td>".$language->get('mail_new_order_date_added').' '.date($language->get('date_format_short'), strtotime($order_query->row['date_added']))."</td>"
."<td align='right' >".$language->get('mail_new_order_order_status') . ' ' . $order_status_query->row['name']."</td>"."</tr>"."</table>"
/*PRODUCTS:*/ ."<strong>".$language->get('mail_new_order_product')."</strong>"
/*Prod. loop*/ ."<table border='1' cellpadding='3' cellspacing='0' width='500' bgcolor='#f4fdd9'>"."<tr>";
foreach ($order_product_query->rows as $result) {
$message .="<tr>"
."<td>".$result['quantity'].'x '."</td>"
."<td>".$result['name'].' ('.$result['model'].')'."</td>"
."<td width='100'>".$this->currency->format($result['total'], $order_query->row['currency'], $order_query->row['value'])."</td>"
."</tr>";};
$message .="</table>"
/*TOTAL:*/ ."<strong>".$language->get('mail_new_order_total')."</strong>"
/*Total loop*/ ."<table border='0' cellpadding='3' cellspacing='0' width='500'>";
foreach ($order_total_query->rows as $result) {
$message .= "<tr><td width='400' align='right'><b>".$result['title']."</b></td><td width='100' border='1' bgcolor='#d9fde3'> ".$result['text']."</td></tr>";};
$message .= "</table>";
/*invoice link*/ //$message .= $language->get('mail_new_order_invoice') . "<br>"
$message .="<a href='".html_entity_decode($this->url->http('account/invoice&order_id='.$order_id))."'><b color='red'>ONLINE INVOICE</b></a><br><br>";
/*Download info*/ if ($order_download_query->num_rows) {
$message .=""
."<strong>".$language->get('mail_new_order_download') ."</strong><br>"
."<table border='1' cellpadding='3' cellspacing='0' width='500'>"
.$this->url->http('account/download')."</table>";
}
/*Comments*/ if ($comment) {
$message .=""
."<strong>".$language->get('mail_new_order_comment') . "</strong><br>"
."<table border='1' cellpadding='3' cellspacing='0' width='500'>"
.$comment."</table>";
}
$message .= $language->get('mail_new_order_footer');
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($order_query->row['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_store'));
$mail->setSubject($subject);
/* html */ $mail->setHtml($message);
$mail->send();
// Mail to Administrator---------------------------------------------
if ($this->config->get('config_alert_mail')) {
/* message start ->*/ $message =""
/*Logo*/ ."<div style='text-align:center'><a href='http://YOURSITE.com'><img src='http://YOURSITE.com/image/logo.png'align='center'/></a></div>"
/*Order recived*/ ."<h2>".$language->get('mail_new_order_received')."<br>".$language->get('mail_new_order_order')."<span style='color:red;'>".$order_id."</span></h2><br>"
."<table border 1 cellpadding='3' cellspacing='0' width='250' bgcolor='#e6edff'>"
.$addressEmail[firstname]." ".$addressEmail[lastname]."<br>"
.$addressEmail[address_1]." - ".$addressEmail[address_2]."<br>"
.$addressEmail[city]." ".$addressEmail[zone]." ".$addressEmail[postcode]."<br>"
.$addressEmail[country]."</table>"
/*date/status*/ ."<table border='0' cellpadding='3' cellspacing='0' width='500'>"."<tr>"
."<td>".$language->get('mail_new_order_date_added').' '.date($language->get('date_format_short'), strtotime($order_query->row['date_added']))."</td>"
."<td align='right' >".$language->get('mail_new_order_order_status') . ' ' . $order_status_query->row['name']."</td>"."</tr>"."</table>"
/*PRODUCTS:*/ ."<strong>".$language->get('mail_new_order_product')."</strong>"
/*Prod. loop*/ ."<table border='1' cellpadding='3' cellspacing='0' width='500' bgcolor='#f4fdd9' >"."<tr>";
foreach ($order_product_query->rows as $result) {
$message .="<tr>"
."<td>".$result['quantity'].'x '."</td>"
."<td>".$result['name'].' ('.$result['model'].')'."</td>"
."<td width='100'>".$this->currency->format($result['total'], $order_query->row['currency'], $order_query->row['value'])."</td>"
."</tr>";};
$message .="</table>"
/*TOTAL:*/ ."<strong>".$language->get('mail_new_order_total')."</strong>"
/*Total loop*/ ."<table border='0' cellpadding='3' cellspacing='0' width='500'>";
foreach ($order_total_query->rows as $result) {
$message .= "<tr><td width='400' align='right'><b>".$result['title']."</b></td><td width='100' border='1' bgcolor='#d9fde3'> ".$result['text']."</td></tr>";};
$message .= "</table>";
/*Download info*/ if ($order_download_query->num_rows) {
$message .=""
."<strong>".$language->get('mail_new_order_download') ."</strong><br>"
."<table border='1' cellpadding='3' cellspacing='0' width='500'>"
.$this->url->http('account/download')."</table>";
}
/*Comments*/ if ($comment) {
$message .=""
."<strong>".$language->get('mail_new_order_comment') . "</strong><br>"
."<table border='1' cellpadding='3' cellspacing='0' width='500'>"
.$comment."</table>";
}
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), $this->config->get('config_smtp_password'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_store'));
$mail->setSubject($subject);
/* html */ $mail->setHtml($message);
$mail->send();
}
}
}
public function update($order_id, $order_status_id, $comment = '', $notifiy = FALSE) {
$order_query = $this->db->query("SELECT *, o.language_id, l.code AS language FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int)$order_id . "' AND o.order_status_id > '0'");
if ($order_query->num_rows) {
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int)$order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notifiy . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()");
if ($notifiy) {
$language = new Language($order_query->row['language']);
$language->load('checkout/confirm');
$subject = sprintf($language->get('mail_update_order_subject'), $this->config->get('config_store'), $order_id);
$message = $language->get('mail_update_order_order') . ' ' . $order_id ."\n";
$message .= $language->get('mail_update_order_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n\n";
$message .= $language->get('mail_update_order_order_status') . "\n\n";
$order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$order_query->row['language_id'] . "'");
$message .= $order_status_query->row['name'] . "\n\n THIS IS THE ONE";
$message .= $language->get('mail_update_order_invoice') . "\n";
$message .= html_entity_decode($this->url->http('account/invoice&order_id=' . $order_id)) . "\n\n";
if ($comment) {
$message .= $language->get('mail_update_order_comment') . "\n\n";
$message .= $comment . "\n\n";
}
$message .= $language->get('mail_update_order_footer');
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($order_query->row['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_store'));
$mail->setSubject($subject);
$mail->setText($message);
$mail->send();
}
}
}
}