Post by bmekwa » Fri Oct 14, 2011 3:54 am

We are using Opencart versions 1.5.1.2 and 1.5.1.1 for our clients. A common request we received from them is about the admin order notification email. Is it possible to improve the admin notification email to include the details Customer name, Payment status, Shipping address.

If those are added, then they can process the order even if they don't have the access to admin area.

I think the notification customer receives contains the above details.

Any help greatly appreciated to add the above details.

And is it possible to make the email notification in HTML format if the receiving email client have the ability to display the email in HTML. If not the text version will be displayed.

Thanks in advance.

Newbie

Posts

Joined
Fri Oct 07, 2011 10:38 pm

Post by scud1096 » Fri Oct 14, 2011 5:38 am

this would be very useful for my customer too

New member

Posts

Joined
Mon Oct 10, 2011 10:04 am

Post by uksitebuilder » Fri Oct 14, 2011 4:53 pm

The easiest solution if for you to receive an exact copy of the customers email.

open catalog/model/checkout/order.php

find

Code: Select all

$mail->setTo($this->config->get('config_email'));			// Admin Alert Mail
			if ($this->config->get('config_alert_mail')) {
				$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
				
				// Text 
				$text  = $language->get('text_new_received') . "\n\n";
				$text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
				$text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
				$text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
				$text .= $language->get('text_new_products') . "\n";
				
				foreach ($order_product_query->rows as $result) {
					$text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
					
					$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
					
					foreach ($order_option_query->rows as $option) {
						$text .= chr(9) . '-' . $option['name'] . (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
					}
				}
				
				$text .= "\n";

				$text.= $language->get('text_new_order_total') . "\n";
				
				foreach ($order_total_query->rows as $result) {
					$text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
				}			
				
				$text .= "\n";
				
				if ($order_info['comment'] != '') {
					$comment = ($order_info['comment'] .  "\n\n" . $comment);
				}
				
				if ($comment) {
					$text .= $language->get('text_new_comment') . "\n\n";
					$text .= $comment . "\n\n";
				}
			
				$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();
				
				// Send to additional alert emails
				$emails = explode(',', $this->config->get('config_alert_emails'));
				
				foreach ($emails as $email) {
					if ($email && preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i', $email)) {
						$mail->setTo($email);
						$mail->send();
					}
				}				
			}		
change to

Code: Select all

			$mail->setTo($this->config->get('config_email'));
			$mail->send();
			// Admin Alert Mail
			if ($this->config->get('config_alert_mail')) {
				$emails = explode(',', $this->config->get('config_alert_emails'));
				
				foreach ($emails as $email) {
					if ($email && preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i', $email)) {
						$mail->setTo($email);
						$mail->send();
					}
				}				
			}		

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by joy » Sun Oct 16, 2011 1:00 am

uksitebuilder wrote:The easiest solution if for you to receive an exact copy of the customers email.
Thank you very much!

But how can I add the Order Status and Additional Comments made by the customer to that email too?
Changes to be made at order.tpl only or what?

OC version 1.5.1.3


joy
New member

Posts

Joined
Fri Oct 14, 2011 9:18 am

Post by uksitebuilder » Sun Oct 16, 2011 3:50 am

catalog/model/checkout/order.php

find

Code: Select all

$template->data['text_footer'] = $language->get('text_new_footer');
add before

Code: Select all

$template->data['text_new_order_status'] = $language->get('text_new_order_status');
$template->data['text_update_comment'] = $language->get('text_update_comment');
find

Code: Select all

$template->data['ip'] = $order_info['ip'];
add after

Code: Select all

$template->data['order_status'] = $order_status;
$template->data['order_comment'] = $order_info['comment'];
open: catalog/view/theme/default/template/mail/order.tpl

find

Code: Select all

<b><?php echo $text_telephone; ?></b> <?php echo $telephone; ?><br />
add after

Code: Select all

<b><?php echo $text_new_order_status; ?></b> <?php echo $order_status; ?><br />
find

Code: Select all

<p><?php echo $text_footer; ?></p>
add before

Code: Select all

<?php if($order_comment!=''){ ?>  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $text_update_comment; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left"><?php echo nl2br($order_comment); ?></td>
      </tr>
    </tbody>
  </table><?php } ?>

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Sun Oct 16, 2011 5:25 am

For those who want it, attached is a vQmod file

Tested on 1.5.1.1/2/3

Attachments


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by scud1096 » Sun Oct 16, 2011 5:52 am

I'll try the vqmod, nice to have! Thank you so much

New member

Posts

Joined
Mon Oct 10, 2011 10:04 am

Post by joy » Sun Oct 16, 2011 10:51 am

uksitebuilder wrote:catalog/model/checkout/order.php

find

Code: Select all

$template->data['text_footer'] = $language->get('text_new_footer');
..........
I am really appreciate! Thank you again!

Just a note, it should be $text_new_comment instead of $text_update_comment.

It does not make any difference if you never edit the description at the catalog/language/[your language]/mail/order.php.
I realised the difference just because I am using a different language and have the different custom description for both.

Another note for this HTML email.
From my test, Gmail won't show the CSS styling, therefore the presentation is no so nice. I changed it to inline style then the borders & header shades all shows and works well.

OC version 1.5.1.3


joy
New member

Posts

Joined
Fri Oct 14, 2011 9:18 am

Post by bmekwa » Thu Oct 20, 2011 12:05 am

Thank you uksitebuilder. I wish to ask about the text appearing in the order notification email. That might be correct for the customer view.

"Thank you for your interest in {Store Name}. Your order has been received and will be processed once payment has been confirmed."

Anyway of modifying this text to different one in admin order notification?

And I have two small questions.
- Will this send/display the text version of email if the receiver email client doesn't support html?
- Payment status will be included in the admin order notification email?

@joy will you mind sharing your edited code with us.

Thanks again.

Newbie

Posts

Joined
Fri Oct 07, 2011 10:38 pm

Post by joy » Thu Oct 20, 2011 1:48 am

bmekwa wrote: "Thank you for your interest in {Store Name}. Your order has been received and will be processed once payment has been confirmed."

Anyway of modifying this text to different one in admin order notification?
The above can be changed at catalog/language/english/mail/order.php
Look for $_['text_new_greeting'] .

Remember, uksitebuilder's solution is to let the admin receive an exact copy of the same email that the customer received after placing the order. Treat it as a cc copy, which means anything you changed is what the customer will get to read.

If what you want is different notification email for admin and customer respectively after an order has been placed, you should look at this thread.
bmekwa wrote:@joy will you mind sharing your edited code with us.
Yes, but on top of adding the order status and customer order comments, I also changed the presentation of the email.

Here is the sample (I don't know much about codes or scripts, i hope it works for you, as it does for me.) :

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $title; ?></title>
</head>
<body style="color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">
<div style="width: 680px;"><a href="<?php echo $store_url; ?>" title="<?php echo $store_name; ?>"><img src="<?php echo $logo; ?>" alt="<?php echo $store_name; ?>" style="margin-bottom: 20px; border: none;" width="200" height="69" /></a>
  <p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_greeting; ?></p>
  <?php if ($customer_id) { ?>
  <p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_link; ?></p>
  <p style="margin-top: 0px; margin-bottom: 20px;"><a href="<?php echo $link; ?>"><?php echo $link; ?></a></p>
  <?php } ?>
  <?php if ($download) { ?>
  <p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_download; ?></p>
  <p style="margin-top: 0px; margin-bottom: 20px;"><a href="<?php echo $download; ?>"><?php echo $download; ?></a></p>
  <?php } ?>
  <table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
    <thead>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;" colspan="2"><?php echo $text_new_order_status; ?> <?php echo $order_status; ?></td> <!-- add the order status -->
      </tr>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;" colspan="2"><?php echo $text_order_detail; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><b><?php echo $text_order_id; ?></b> <?php echo $order_id; ?><br />
          <b><?php echo $text_date_added; ?></b> <?php echo $date_added; ?><br />
          <b><?php echo $text_payment_method; ?></b> <?php echo $payment_method; ?><br />
          <?php if ($shipping_method) { ?>
          <b><?php echo $text_shipping_method; ?></b> <?php echo $shipping_method; ?>
          <?php } ?></td>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><b><?php echo $text_email; ?></b> <?php echo $email; ?><br />
          <b><?php echo $text_telephone; ?></b> <?php echo $telephone; ?><br />
          <!-- <b><?php echo $text_new_order_status; ?></b> <?php echo $order_status; ?><br />  add the order status -->
          <b><?php echo $text_ip; ?></b> <?php echo $ip; ?><br /></td>
      </tr>
    </tbody>
  </table>
 <table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
    <thead>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_payment_address; ?></td>
        <?php if ($shipping_address) { ?>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_shipping_address; ?></td>
        <?php } ?>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $payment_address; ?></td>
        <?php if ($shipping_address) { ?>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $shipping_address; ?></td>
        <?php } ?>
      </tr>
    </tbody>
  </table>
  <table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
    <thead>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_product; ?></td>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_model; ?></td>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_quantity; ?></td>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_price; ?></td>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_total; ?></td>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($products as $product) { ?>
      <tr>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $product['name']; ?>
          <?php foreach ($product['option'] as $option) { ?>
          <br />
          &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
          <?php } ?></td>
        <td style="vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $product['model']; ?></td>
        <td style="vertical-align: top; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $product['quantity']; ?></td>
        <td style="vertical-align: top; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $product['price']; ?></td>
        <td style="vertical-align: top; padding: 0px 5px; text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $product['total']; ?></td>
      </tr>
      <?php } ?>
    </tbody>
    <tfoot>
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td colspan="4" style="text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><b><?php echo $total['title']; ?>:</b></td>
        <td style="text-align: right; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $total['text']; ?></td>
      </tr>
      <?php } ?>
    </tfoot>
  </table>
  <!-- add on order comments by customer -->
 <?php if($order_comment!=''){ ?>  
 <table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
    <thead>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_new_comment; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo nl2br($order_comment); ?></td>
      </tr>
    </tbody>
  </table><?php } ?>
  <?php if ($comment) { ?>
    <table style="border-collapse: collapse; width: 100%; border-top: 1px solid #DDDDDD; border-left: 1px solid #DDDDDD; margin-bottom: 20px;">
    <thead>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; background-color: #EFEFEF; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $text_instruction; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td style="text-decoration: none; color: #222222; font-weight: bold; vertical-align: top; padding: 0px 5px; text-align: left; padding: 7px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD;"><?php echo $comment; ?></td>
      </tr>
    </tbody>
  </table>
  <?php } ?>
  <p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_footer; ?></p>
  <p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_powered; ?></p>
</div>
</body>
</html>

OC version 1.5.1.3


joy
New member

Posts

Joined
Fri Oct 14, 2011 9:18 am

Post by markman-b » Fri Oct 21, 2011 7:07 pm

uksitebuilder wrote:For those who want it, attached is a vQmod file

Tested on 1.5.1.1/2/3

Ehhh....who wants it not? Ordermails to the storeowner should be treated standard this way in OC.

Thanx a lot. Works fine.

OC version 1.5.4.1


Active Member

Posts

Joined
Wed Aug 24, 2011 7:13 pm

Post by uksitebuilder » Sun Oct 23, 2011 3:16 am

I meant the vqmod file ;)

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by SandCarver » Tue Nov 15, 2011 11:18 pm

Simon,

Thank you so much for the VQMod version of the invoice - I have been bothered by the standard emails that we receive internally ever since upgrading. Your bit of code made the change easy.

Thanks again!

Checkout Our OpenCart powered Stores
Sandcarving Systems | Glass Banks


Newbie

Posts

Joined
Wed Nov 17, 2010 11:14 pm

Post by JayJay » Sun Nov 20, 2011 7:32 pm

Thanks! OpenCart is Awesome!

Newbie

Posts

Joined
Wed Oct 19, 2011 5:08 pm

Post by jp1976 » Mon Nov 21, 2011 1:55 am

hi all, i have copied mi vqmod folder from locale to server, and dont work. why? can i need to modify some file?
in local installation it worx fine, but not ion my web server.

last version OC+last version vqmod

New member

Posts

Joined
Mon Oct 31, 2011 12:01 am

Post by jp1976 » Mon Nov 21, 2011 2:58 pm

i dont see errors in my vqmod log

New member

Posts

Joined
Mon Oct 31, 2011 12:01 am

Post by jp1976 » Tue Nov 22, 2011 1:53 am

anyone can help me?
my website link: lab.blurdesign.biz

New member

Posts

Joined
Mon Oct 31, 2011 12:01 am

Post by jp1976 » Tue Nov 22, 2011 3:16 am

"RESOLVED": i have set all files and folders in vqmod folder to 777 and... TA-DA... it worx, but this is a crazy solution. So i have a problem with file permissions, can u help me with this now? If u suggest me the right permissions i can apply to my files and folders.
And.. finally... a guide to OC file permissions?

Best.

New member

Posts

Joined
Mon Oct 31, 2011 12:01 am

Post by rocket » Wed Jan 11, 2012 8:00 pm

Can't get the vQmod to work in my store v1.5.1.3
Its installed but doesn't send me a copy of the customers email, any help?

Not to worry, installed the whole site again and this works now!

User avatar
New member

Posts

Joined
Sat Oct 22, 2011 12:09 am

Post by clapiana » Fri Feb 24, 2012 4:37 am

the above xml works great thanks!

anybody know how to add the order total to the email subject line of an order in 1513 ?

New member

Posts

Joined
Thu Sep 01, 2011 6:22 pm
Who is online

Users browsing this forum: No registered users and 122 guests