Opencart, PHP

Opencart 1.5.x – HTML Email Notification for Admin

You might have noticed that in Opencart 1.5.x versions, the admin only gets the text order notification like below:

Opencart Admin - Text Email Notification

This is okay but it doesn’t show the customer name, address and other details unlike the email notification that the customer receives.

If you want the admin to get the same email as the customer (complete with shipping and payment details), find the file:

catalog/model/checkout/order.php

find the lines:

$mail = new Mail(); 
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject($subject);
$mail->setText($text);
$mail->send();

and replace them with the code below:

// HTML
$template->data['text_greeting'] = $language->get('text_new_received') . "\n\n";
$template->data['invoice_no'] = '';
$template->data['text_invoice_no'] = '';
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');
}
$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
$mail->setSubject($subject);
$mail->setTo($this->config->get('config_email'));
$mail->setHtml($html);
$mail->send();

and your done! The admin will get the same email as the customer like below:

Opencart Admin - HTML Email Notification

NOTE: TESTED ON OPENCART 1.5.x VERSIONS ONLY.