If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Managing Customers and Orders / Copy of orders to different email addresses?

Copy of orders to different email addresses?

Started by melodyw on 22 Jan 2013, 10:33 AM · Views: 952

Results 1 to 6 of 6
22 Jan 2013, 10:33 AM
#1
melodyw avatar

melodyw

New Zenner

Join Date:
Feb 2010
Posts:
32
Plugin Contributions:
0

Post #1 by melodyw

We have a requirement whereby when an engineer places an order an e-mail copy of the order needs to be sent to his line manager, therefore there will be numerous line managers with different e-mail addresses.

Does anyone know if this is possible and how I would go about it?

Thank you

22 Jan 2013, 11:11 AM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Post #2 by stevesh

I don't think there's any way to do that in Zencart. We did something similar by assigning email addresses to users which had forwarders set up to send to the user's actual email address and to his manager. This assumes that all your engineers are internal and Zencart accounts are set up for them.

22 Jan 2013, 11:12 AM
#3
drbyte avatar

drbyte

Sensei

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

Post #3 by drbyte

Here's the basic concept --- you'll have to work out your own way of determining what the line-manager's email address is. You didn't mention how the store would know the correct email address. Simply add that logic into the code below.

  1. /includes/classes/observers/class.sendLineManagerOrderNotices.php
<?php
/**
 * observer class to send custom extra order emails
 *
 * @package classes
 * @copyright Copyright 2003-2013 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: class.sendLineManagerOrderNotices.php   $
 */
class sendLineManagerOrderNotices extends base {

 /**  constructor method !
   *
   * Attach observer class to the global $zco_notifier and watch for a single notifier event.
   */
  function __construct() {
    $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
  }


 /**   Actual Method that does the desired activity
   *
   * Called by observed class when any of the notifiable events occur
   *
   * @param object $class
   * @param string $eventID
   * @param array $paramsArray
   */
  function update(&$class, $eventID, $paramsArray = array()) {
    list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;

    $manager_email_address = $this->lookup_manager_email_address($_SESSION['customer_id']);

    if ($manager_email_address != '') {
      zen_mail('', $manager_email_address,
          EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
          $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra');
    }
  }

  function lookup_manager_email_address($employee_id) {
    global $db;
    $sql = "put your SQL query here -- needs to look up the destination manager's email address based on supplied $employee_id"
    $result = $db->Execute($sql);
    $email_address = $result->fields['manager_email'];
    return $email_address;
  }

}
  1. /includes/auto_loaders/config.sendLineManagerOrderNotices.php
<?php
/**
 * autoloader activation point for custom group order email notices
 *
 * @package initSystem
 * @copyright Copyright 2003-2013 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: config.sendLineManagerOrderNotices.php $
 */
/**
 * Autoloader to instantiate observer class
 */
$autoLoadConfig[90][] = array('autoType'=>'class',
                              'loadFile'=>'observers/class.sendLineManagerOrderNotices.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                              'className'=>'sendLineManagerOrderNotices',
                              'objectName'=>'sendLineManagerOrderNotices');

Adapted from http://www.zen-cart.com/showthread.php?155959-email-order-confirmation-to-third-party&p=889507#post889507 ... which may also be worth a read

.
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.

22 Jan 2013, 12:29 PM
#4
melodyw avatar

melodyw

New Zenner

Join Date:
Feb 2010
Posts:
32
Plugin Contributions:
0

Post #4 by melodyw

Thank you for your help.

At this stage I'm not sure how the store will know which e-mail address to send the order to. I'm wondering if I can add an extra field to customer details.

At least I now know this can be achievable.

22 Jan 2013, 3:19 PM
#5
terragirl avatar

terragirl

Zen Follower

Join Date:
Jun 2010
Location:
Austria
Posts:
123
Plugin Contributions:
0

Post #5 by terragirl

I think you're on the right track. I'd make the line manager email a customer field so it's part of their account (same as their own email), assuming that the line manager email remains fairly static and does not change with each order. They enter it when they create an account & then order emails go to both.

25 Feb 2013, 4:14 PM
#6
melodyw avatar

melodyw

New Zenner

Join Date:
Feb 2010
Posts:
32
Plugin Contributions:
0

Post #6 by melodyw

Hi

I want to add a field to customer accounts called Line Manager's email address and I will need the order confirmation also to go to this e-mail address.

Any help would be much appreciated as I don't know how to go about this.

Many thanks

Regards

Mel