New Zenner
- Join Date:
- Feb 2010
- Posts:
- 32
- Plugin Contributions:
- 0
Order confirmation to third party email - PROBLEM
I am trying to set up order confirmations to go to different e-mail addresses dependant on customer group.
I did get group 1 to work but couldn't get any other group to work. Now no groups are working.
Here is my code in 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'));
/**
* 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;
}
/** 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) {
$this->specialGroupEmailAddress = '';
switch($group_query->fields['customers_group_pricing']) {
case '1':
$this->specialGroupEmailAddress = '[email protected]';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '2':
$this->specialGroupEmailAddress = 'email_address_for_group_2@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
case '3':
$this->specialGroupEmailAddress = 'email_address_for_group_3@e_mail.com';
$this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
break;
default:
}
if ($this->specialGroupEmailAddress != '')
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);
}
}
}
Any help / advice would be much appreciated.
Many thanks
Regards
Mel