Page 5 of 5 FirstFirst ... 345
Results 41 to 47 of 47
  1. #41
    Join Date
    Jul 2012
    Posts
    99
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    Thanks for the addition of information.

  2. #42
    Join Date
    Jul 2012
    Posts
    99
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    I was making some more testing than sometime it was working and some other time it didn't. Strange situation... So I found a problem in the code. In this part:
    PHP Code:
    <?php

      
    function update(&$class$eventID$paramsArray = array()) {
        global 
    $db;
        list(
    $zf_insert_id$email_order$extra_info$html_msg) = $paramsArray;
        
    $group_query $db->Execute("select products_options_value_id from " zen_customers_basket_attributes " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if (!
    $group_query->EOF) {
          
    $this->ClubEmailAddress '';
          switch(
    $group_query->fields['products_option_value_id']) {
            case 
    '6':
              
    $this->ClubEmailAddress '[email protected]';
              
    $this->orderEmailSubjectPrefix 'Demande de confirmation de membre par ' STORE_NAME;
              break;
            case 
    '9':
              
    $this->ClubEmailAddress '[email protected]';
              
    $this->orderEmailSubjectPrefix 'Demande de confirmation de membre par ' STORE_NAME;
              break;
            case 
    '10':
              
    $this->ClubEmailAddress '[email protected]';
              
    $this->orderEmailSubjectPrefix 'Demande de confirmation de membre par ' STORE_NAME;
              break;
            case 
    '12':
              
    $this->ClubEmailAddress '[email protected]';
              
    $this->orderEmailSubjectPrefix 'Demande de confirmation de membre par ' STORE_NAME;
              break;
            default:
          }
    I'm trying to get the "products_options_value_id" in the "zen_customers_basket_attributes" but it's not logical since it's not in the basket that I need to look but in the order! In "zen_orders_products_attributes" in fact. The basket is getting empty after the transaction that why it wasn't working. I don figure why it works few times but It's logical if it doesn't

    So instead of
    Code:
    Execute("select products_options_value_id from " . zen_customers_basket_attributes . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'")
    I think I should ask for something more like
    Code:
    Execute("select products_options_values_id from " . zen_orders_products_attributes . " where orders_products_id = '" . (int)$_SESSION['orders_products_id'] . "' and where products_options_id = '8'")
    Am I ok with this code? Does it make sens?

  3. #43
    Join Date
    Jul 2012
    Posts
    99
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    I know everyone are very busy but I need help here please to have this query to work.

    Concretely, I need to get the option value id of the current order when there is a specific type of option in it. What I use is the following but it's not working and I need help to make it work.

    When I run this in phpMyAdmin it gives me the result I'm looking for.
    SELECT products_options_values_id
    FROM zen_orders_products_attributes
    WHERE orders_products_id =27
    AND products_options_id =4

    Off course the current order is #27. But the following code I use is not working:
    Code:
    $group_query = $db->Execute("select products_options_values_id from " . zen_orders_products_attributes . " where orders_products_id = '" . $zf_insert_id . "' and products_options_id = '4'").
    I'm pretty sure the problem is about getting current order number which is the "order product id" in the table. I don't know much about the variable transfert data syntax so I really need your help please!

  4. #44
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: email order confirmation to third party

    This speaks to an ongoing ambiguity in all your posts here, where there seems to be an assumption that your customers are always ONLY purchasing ONE product with only ONE attribute selected, because your code does nothing to accommodate different notices to other vendors based on a purchase of multiple items in the cart.

    For example, your query above only works if the FIRST option value id is a match, and ignores all other option value ids.

    Better to loop through the $class->products array, and for each product in that array, loop through the corresponding $class->products[$i]['attributes'] array to find all the ['values_id'] elements, and compare those against your list of special cases. This is the most accurate data to work from, and is more efficient instead of making a number of new database queries needlessly.

    Code:
        for ($i=0, $n=sizeof($class->products); $i<$n; $i++) {
          if (isset($this->products[$i]['attributes'])) {
            for ($j=0, $n2=sizeof($class->products[$i]['attributes']); $j<$n2; $j++) {
              switch($class->products[$i]['attributes'][$j]['value_id']) {
    
    //.... all your case statements here ...
    
              } // end switch
            }  // end for
          }  // end if
        } // end for
    .

    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.

  5. #45
    Join Date
    Jul 2012
    Posts
    99
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    In fact, customers can buy many other products as they want but only one member card, which has this attribute (products_options_id = '4'). There's an extra email that needs to be send to the address associated to this attribute's value selected from a drop down list.

    So yes, only one item by order will need this email to be send.

    I hope my understanding of what you said is good, my english is far than perfect...
    Last edited by AlexThibo; 30 Oct 2013 at 12:26 AM.

  6. #46
    Join Date
    Jul 2012
    Posts
    99
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    That's what works:

    Code:
      function update(&$class, $eventID, $paramsArray = array()) {
        global $db;
        list($zf_insert_id, $email_order, $extra_info, $html_msg) = $paramsArray;
        $group_query = $db->Execute("select products_options_values_id from zen_orders_products_attributes where orders_products_id ='". intval($zf_insert_id) ."' and products_options_id = '4'");
    
        if (!$group_query->EOF) {
          $this->ClubEmailAddress = '';
          switch($group_query->fields['products_options_values_id']) {
            case '6':
              $this->ClubEmailAddress = '[email protected]';
              $this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
              break;
            case '7':
              $this->ClubEmailAddress = '[email protected]';
              $this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
              break;
            case '8':
              $this->ClubEmailAddress = '[email protected]';
              $this->orderEmailSubjectPrefix = 'Demande de confirmation de membre par la ' . STORE_NAME;
              break;
    		default:
    		   $this->ClubEmailAddress = '';
              break;
    	  }
    	  if ($this->ClubEmailAddress != '') 
    		zen_mail('', $this->ClubEmailAddress,
    		  $this->orderEmailSubjectPrefix,
    		  $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $this->attachArray);
      	}
      }
    }

  7. #47
    Join Date
    Sep 2010
    Posts
    24
    Plugin Contributions
    0

    Default Re: email order confirmation to third party

    Quote Originally Posted by DrByte View Post
    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:

    1. Edit /includes/classes/order.php and change just one line near the very end of the file:
    Code:
        $this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL');
    becomes this:
    Code:
        $this->notify('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL', array($zf_insert_id, $email_order, $extra_info, $html_msg));
    2. Create a new file with the following content:
    /includes/classes/observers/class.sendGroupOrderNotices.php
    Code:
    <?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 && $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
    Code:
    <?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');
    Can this be done for manufacturer? If customer order some product manufacturer also receive confirmation email.

 

 
Page 5 of 5 FirstFirst ... 345

Similar Threads

  1. v153 When order is in "Processing" status send email to third party
    By jdlauletta in forum General Questions
    Replies: 0
    Last Post: 6 Nov 2014, 08:07 PM
  2. v150 Order confirmation to third party email - PROBLEM
    By MelodyW in forum Managing Customers and Orders
    Replies: 3
    Last Post: 23 Apr 2013, 03:11 PM
  3. Third party templates
    By travellers in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 9 Jan 2009, 03:31 PM
  4. Third Party Gift Certificate
    By BazM in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 25 Nov 2008, 11:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR