valnoren, using Zen Cart v1.3.9x, it's very simple.
You could hard-code lotsa stuff into the orders class, or you could go with a more sophisticated approach using notifiers/observers as I've outlined below:
- Edit /includes/classes/order.php and change just one line near the very end of the file:
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');becomes this:```
$this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'[B], array($zf_insert_id, $email_order, $extra_info, $html_msg)[/B]);
2. Create a new file with the following content:
/includes/classes/observers/class.sendGroupOrderNotices.php
<?php
/**
* observer class to send custom extra order emails to supplier based on customer group membership
*
* @package classes
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*
@version $Id: class.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
class sendGroupOrderNotices extends base {
/** constructor method !
*
* Attach observer class to the global $zco_notifier and watch for a single notifier event.
*/
function sendGroupOrderNotices() {
$this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
[B] /**
* Set the specialGroupId to the number of the customer-group assigned in your admin
*/
$this->specialGroupId = 1;
/**
* Set the proper email address for the additional copy of order confirmations to be sent to
*/
$this->specialGroupEmailAddress = 'noreply@mail_domain.com';
/**
* Set the email subject line for the messages being sent to the external supplier
* Use EMAIL_TEXT_SUBJECT for the default subject, or replace with 'My Custom Subject Line' instead.
*/
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;[/B]
}
/** Actual Method that does the desired activity
*
* Called by observed class when any of the notifiable events occur
*
* @param object $class
* @param string $eventID
*/
function update(&$class, $eventID, $paramsArray = array()) {
global $db;
list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;
$group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
if (!$group_query->EOF && $group_query->fields['customers_group_pricing'] == $this->specialGroupId) {
zen_mail('', $this->specialGroupEmailAddress,
$this->orderEmailSubjectPrefix . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
$email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
}
}
}
```You can
**customize the section in red, as needed.
**
3. Create a new file with the following content:
/includes/auto_loaders/config.sendGroupOrderNotices.php```
<?php
/**
* autoloader activation point for custom group order email notices
*
* @package initSystem
* @copyright Copyright 2003-2010 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*
@version $Id: config.sendGroupOrderNotices.php 2010-05-26 20:05:22Z drbyte $
*/
/**
* Autoloader to instantiate observer class
*/
$autoLoadConfig[90][] = array('autoType'=>'class',
'loadFile'=>'observers/class.sendGroupOrderNotices.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'sendGroupOrderNotices',
'objectName'=>'sendGroupOrderNotices');
```
.
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.