Forums / General Questions / Order Confirmation Emails Question

Order Confirmation Emails Question

Started by jimweinberg on 1 Aug 2012, 6:47 PM · Views: 1,437

Results 1 to 15 of 15
1 Aug 2012, 6:47 PM
#1
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Order Confirmation Emails Question

Is it possible to have 2 different Order Confirmation emails, one that is sent to the customer and one that is sent to the store manager/admin?

Thanks.

1 Aug 2012, 7:17 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Order Confirmation Emails Question

jimweinberg:

Is it possible to have 2 different Order Confirmation emails, one that is sent to the customer and one that is sent to the store manager/admin?

Thanks.

Yes...

All email settings are controlled in ADMIN >>> CONFIGURATION >>> EMAIL SETTINGS#

Follow the examples given of how to set up multiple recipients.

20 years a Zencart User

1 Aug 2012, 8:25 PM
#3
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

Hi Scoolboy.

Perhaps I didn't make myself clear. I want to send two different confirmation emails, not send a single email to two different people. The CP seems to only let you do the latter.

2 Aug 2012, 8:03 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Order Confirmation Emails Question

jimweinberg:

Is it possible to have 2 different Order Confirmation emails, one that is sent to the customer and one that is sent to the store manager/admin?
The default Zen Cart code takes the same email that was sent to the customer, adds an office-use-only section to it, and sends that to the storeowner.
But you can of course rewrite the code to do whatever you like.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Aug 2012, 9:12 PM
#5
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

DrByte.

Thanks for the reply. I figured I'd probably have to do some coding to have this done. Can you tell me which file(s) I will need to modify?

Thanks.

2 Aug 2012, 10:06 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Order Confirmation Emails Question

Order-Confirmation emails are generated in the orders.php class file.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2012, 2:20 PM
#7
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

Hi DrByte.

Again, thanks for the reply. I found the order.php file under classes, and it definitely looks like the one I need to modify. One question, it doesn't look like there's an override function for the classes files. Can I create one by just copying the order.php file into a classes/<my template> folder?

Again, thanks.

Regards.

3 Aug 2012, 5:04 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,127
Plugin Contributions:
56

Re: Order Confirmation Emails Question

You're right, there is no override for the classes ... but there is an override possibility using an "observer". If you look in the order.php file, towards the bottom is the function send_order_email. Within that function there are two "notifiers" that it raises; the one you'd be interested in is NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS, which is raised just before the "admin/extra" email is sent. You could write an "observer" that is invoked when the notifier is raised and perform your custom processing without changing any core files. The wiki documentation is here: http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials.

The COWOA plugin makes use of an observer class to do its business and might help to guide you.

3 Aug 2012, 6:54 PM
#9
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

Hi lat9.

Thanks for the reply. I appreciate the info and will look into using a notifier. Fortunately, I managed to create the new "owner's email" within the order.php file (and, yes, I made a backup first :smile:).

You might be able to help me with a minor problem, if you would be so kind.

The original email contained 3 items: a disclaimer, a copyright notice and an anti-spam notice. They looked like this:

-----
This email address was given to us by you or by one of our customers. If you
feel that you have received this email in error, please send an email to
[email protected] 


-----
Copyright (c) 2012 Along Crazy Alley. Powered by Zen Cart


This email is sent in accordance with the US CAN-SPAM Law in effect
01/01/2004. Removal requests can be sent to this address and will be honored
and respected.

In the code for the new email, I commented out what I thought were the lines that generated these, so the section looks like this:

/*    // include disclaimer
    $email_order .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
    // include copyright
    $email_order .= "\n-----\n" . EMAIL_FOOTER_COPYRIGHT . "\n\n";
*/

    while (strstr($email_order, ' ')) $email_order = str_replace(' ', ' ', $email_order);

    $html_msg['EMAIL_FIRST_NAME'] = $this->customer['firstname'];
    $html_msg['EMAIL_LAST_NAME'] = $this->customer['lastname'];
    //  $html_msg['EMAIL_TEXT_HEADER'] = EMAIL_TEXT_HEADER;
    $html_msg['EXTRA_INFO'] = '';
    $zco_notifier->notify('NOTIFY_ORDER_INVOICE_CONTENT_READY_TO_SEND', array('zf_insert_id' => $zf_insert_id, 'text_email' => $email_order, 'html_email' => $html_msg));
//    zen_mail($this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id, $email_order, STORE_NAME, EMAIL_FROM, $html_msg, 'checkout', $this->attachArray);

      zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, 'NEW ORDER' . ' ' . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
      $email_order, STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
    }
    $zco_notifier->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');
  }

The resulting email section now looks like this:

This email address was given to us by you or by one of our customers. If you
feel that you have received this email in error, please send an email to
[email protected] 
This email is sent in accordance with the US CAN-SPAM Law in effect
01/01/2004. Removal requests can be sent to this address and will be honored
and respected.

You'll notice that the copyright statement is gone, but the other 2 are still there. Any idea where/how they're being generated?

Anyway, thanks for your help.

BTW, in your reply you said to look for the notifier: NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS. No such notifier is in the copy of order.php that I have. No biggie, just FYI.

Regards.

3 Aug 2012, 7:52 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,127
Plugin Contributions:
56

Re: Order Confirmation Emails Question

I think I remember seeing some "issues" with bracketing comments around line comments; try this instead:

/*    
    // include disclaimer
    $email_order .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
    // include copyright
    $email_order .= "\n-----\n" . EMAIL_FOOTER_COPYRIGHT . "\n\n";
*/

Note that the bracketing comment starts on a line before the line (//) comment. The notifier constant that I mentioned is in the v1.5.0 version of order.php.

3 Aug 2012, 8:40 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Order Confirmation Emails Question

jimweinberg:

BTW, in your reply you said to look for the notifier: NOTIFY_ORDER_INVOICE_CONTENT_FOR_ADDITIONAL_EMAILS. No such notifier is in the copy of order.php that I have. No biggie, just FYI.
That was added in v1.5.0. You're using a much older version which doesn't have that option.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2012, 9:14 PM
#12
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

Hey lat9:

I tried that. No go. In fact, I got frustrated and deleted all 6 lines. Same result. Don't understand it!

4 Aug 2012, 9:09 PM
#13
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,127
Plugin Contributions:
56

Re: Order Confirmation Emails Question

I think you might be getting "bit" by the zen_mail function itself. Look in /includes/functions/functions_email.php; my copy has the following version information:

/**
 * functions_email.php
 * Processes all outbound email from Zen Cart
 * Hooks into phpMailer class for actual email encoding and sending
 *
 * @package functions
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: functions_email.php 19325 2011-08-02 22:09:43Z drbyte $
 * 2007-09-30 added encryption support for Gmail Chuck Redman
 */

Starting at line 114, there's this code fragment that might be the source of your problem:

      if ($module != 'xml_record') {
        if (!strstr($email_text, sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS)) && $to_email_address != STORE_OWNER_EMAIL_ADDRESS && !defined('EMAIL_DISCLAIMER_NEW_CUSTOMER')) $email_text .= "\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS);
        if (defined('EMAIL_SPAM_DISCLAIMER') && EMAIL_SPAM_DISCLAIMER != '' && !strstr($email_text, EMAIL_SPAM_DISCLAIMER) && $to_email_address != STORE_OWNER_EMAIL_ADDRESS) $email_text .= "\n\n" . EMAIL_SPAM_DISCLAIMER;
      }
5 Aug 2012, 1:22 PM
#14
jimweinberg avatar

jimweinberg

New Zenner

Join Date:
Jul 2012
Posts:
33
Plugin Contributions:
0

Re: Order Confirmation Emails Question

Hey lat9.

Yea, I figured it was being done somewhere outside the order routine. You're probably right that it's in the functions_email routine. Looking at the code, however, it looks like the disclaimers shouldn't be included if the email is going to the store owner. I'll look at the code further this afternoon and see if it's being added somewhere else in the routine.

Thanks for sticking with this. You are truly Totally Zenned.

Regards.

5 Aug 2012, 5:40 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Order Confirmation Emails Question

What exactly did you change in the code?

It sounds like you want to send a completely different email to a completely different address. What's the business purpose for this other email you're sending? Why are you wanting to make these changes?
It's often helpful to know the full back-story in order to give you the specific answer you need.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.