Zen Cart Logo
Forums / Managing Customers and Orders / Order confirmation to third party email - PROBLEM

Order confirmation to third party email - PROBLEM

Views: 1,979

Results 1 to 4 of 4
14 Apr 2013, 9:24 AM
#1
melodyw avatar

melodyw

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

19 Apr 2013, 10:19 AM
#2
melodyw avatar

melodyw

New Zenner

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

Re: Order confirmation to third party email - PROBLEM

As I have had no reply I am guessing no one knows how to do this?

If somebody could help me with PHP code and ge this working I would be prepared to pay.

Regards

Mel

19 Apr 2013, 7:50 PM
#3
drbyte avatar

drbyte

Sensei

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

Re: Order confirmation to third party email - PROBLEM

The email addresses you've entered for all the groups don't look like they're real addresses.
And do your group numbers match the "case" statements in the code? If not, then those scenarios won't trigger, and thus the emails won't be sent.

23 Apr 2013, 2:11 PM
#4
melodyw avatar

melodyw

New Zenner

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

Re: Order confirmation to third party email - PROBLEM

Hi DrByte

I originally tried it and put in proper e-mail addresses but it didn't seem to work, I have just put them back in and no joy.

<?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 = 'melodyw@REAL_SITE_HERE.co.uk';
    /**
     * 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 = 'melody.wootton@REAL_SITE_HERE.co.uk';
          $this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
          break;
        case '2':
          $this->specialGroupEmailAddress = 'stevesham@REAL_SITE_HERE.co.uk';
          $this->orderEmailSubjectPrefix = 'Order Fulfillment Request from ' . STORE_NAME;
          break;
        case '3':
          $this->specialGroupEmailAddress = 'melodyw@REAL_SITE_HERE.co.uk';
          $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);
    }
  }
} 

Do you have any idea why this isn't working? I'm sure it's something really silly but I don't really know much PHP and I'm pulling my hair out!

Thanks in advance.