Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34
  1. #1
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Customizing confirmation e-mail

    I am working on modifying the order confirmation e-mail to make printable tags for the customer, using the notifiers to avoid editing order.php. (I had previously edited the order.php subject-creation code for admin e-mails to give more useful information on the order content.) My site is www.nyfaeriefest.com, still on v1.5.0, upgraded many times (from v1.3.small?) since 2008. The only relevant parts for this function are order.php and the observer/notifier system.

    I believe I have correctly written the files for using the attribute output to create extra text blocks that customers can print out and bring for ready-made car and tent tags when they arrive at the festival; but there are a few items I am not certain about.

    PHP Code:
    <?php
    /**
     * File contains the car & tent tag building code for confirmation e-mail
     *
     * //@package classes
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @copyright Copyright 2003-2007 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: order_tag_builder.php 2017-03-19 gjh42 $
     */
     
    /*order.php line 795ff
              $sql_data_array = array('orders_id' => $zf_insert_id,
                                      ...
                                      'products_options' => $attributes_values->fields['products_options_name'],
                                      'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      ...
                                      'products_prid' => $this->products[$i]['id']
                                      );

              zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
    //called from order class (order.php) by
              $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);
     */
    class orderTagBuilder extends base {
      function 
    __construct() {
        global 
    $zco_notifier;
        
    $zco_notifier->attach($this, array('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM','NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS'));
        
    //-------------------------to build tag info---------------------------------------to add tag text to content
      
    }
    /**
       * Update Method
       * Called by observed class when any of our notifiable events occur
       * @param object $class
       * @param string $eventID
    */
      
    function update(&$class$eventID$paramsArray = array()) {
        if(!
    is_array($tag_info)) global $tag_info = array();
        if(!isset(
    $tag_qty)) global $tag_qty 0;
        if(
    $eventID == 'NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM') {
          if(
    in_array($sql_data_array[products_prid, array[7,15,17,18,24,25],true) {//process tag info
            
    if(!isset(tag_qty)) $tag_qty 0;
            if(!
    is_array($tag_info)) $tag_info = array;
            if(
    $sql_data_array[products_options] == 'Name') {
              
    $tag_info[$tag_qty] .= '<br /><strong>-----------------------------------<br />' $sql_data_array[products_options_value] . '</strong><br />';
              
    $tag_qty++;
            }
            if(
    in_array($sql_data_array[products_options], array['Dates','Onsite phone','Vehicle','Zone preference']) {
              
    $tag_info[$tag_qty] .= $sql_data_array[products_options] . ': <strong>' $sql_data_array[products_options_value] . '</strong><br />';
            }
          }
        }
      }
    //end build tag info

    /* called by notify end of product attributes:
        $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS', $custom_insertable_text);
    /* START: ADD MY CUSTOM DETAILS
     * 1. calculate/prepare custom information to be added to this product entry in order-confirmation.
     * 2. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
     *      $this->products_ordered_attributes .=  {INSERT CUSTOM INFORMATION HERE};
     */
      
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
        if(
    is_array($tag_info)) {//add tags if they exist
          
    foreach($tag_info[] as $tag_qty,$tag_text) {
            
    $custom_insertable_text .= '<br /><br /><br />';
            if(
    strpos($tag_text,'Vehicle') /== false) {//add car tag
              
    $custom_insertable_text .= '
    <br /><br /><br /><h2><strong>------------------------------------------<br />CAR TAG</strong></h2><br />' 
    $tag_text '<br /><br /><br />';
            }
            
    //add tent tag
            
    $custom_insertable_text .= '
    <h2><strong>------------------------------------------<br />TENT TAG</strong></h2><br />' 
    $tag_text '<br /><br /><br />';
          }
        }
        
    $this->products_ordered_attributes .=  $custom_insertable_text;//can i do this here?
        
    unset $tag_info$tag_qty;//in case the customer wants to make another order
      
    }//end add tag text to content
    }
    //eof
    PHP Code:
    <?php
    /*
     * //@package autoloaders (In includes/auto_loaders)
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: config.orderTagBuilder.php 2017-03-19 gjh42 $
     */

    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  
    'loadFile'=>'observers/orderTagBuilder.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  
    'className'=>'orderTagBuilder',
                                  
    'objectName'=>'orderTagBuilder');
    /*Note: 10 has been chosen to cause the observer class to be loaded before the session is started. 
    Note: 90 has been chosen as the offset since the observer needs to attach to the $SESSION['cart?order?'] class, which is instantiated at offset 80??. 
    */
    //eof
    The code will have to run the tag item code half a dozen separate times for each person in the order, so it needs to remember its previous state.
    if(!is_array($tag_info)) global $tag_info = array();
    if(!isset($tag_qty)) global $tag_qty = 0;
    is intended to do this; is this a good way? Any drawbacks?

    Will
    $zco_notifier->attach($this, array('NOTIFY_ORDER_...
    correctly connect to order.php? This the first time I have actually tried the observer/notifier system. I would have done so in previous mods, but what I needed to do previously required changing stock behavior, not adding new behavior.

    Order.php has notes about using $custom_insertable_text to return such info, but there is no active code in place to append it without editing order.php. I would have no issue with doing that as I have already done so for another purpose, but if it can be avoided, so much the better. Can I update $this->products_ordered_attributes in the observer, or do I have to go back to order.php to do it?

    I will get a testbed set up to try this out, but can't do it right now, so am hoping for some expert guidance in the meantime.

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

    Default Re: Customizing confirmation e-mail

    Quote Originally Posted by gjh42 View Post
    Will
    $zco_notifier->attach($this, array('NOTIFY_ORDER_...
    correctly connect to order.php?
    The notifier hook you attach to causes the code to jump into the observer class and fire the update() function as if the code was (almost) inserted where the notifier hook is located. Basically a "gosub" call if you ever used BASIC as a language.
    I say "almost" because it doesn't have access to all the non-$this variables.

    Quote Originally Posted by gjh42 View Post
    Can I update $this->products_ordered_attributes in the observer
    Nearly. Your update() function passes &$class as the first parameter, so to update any $this variables in that class, simply refer to them using $class-> instead.

    For example: $class->products_ordered_attributes = $whatever_value;
    .

    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.

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    Great, thanks, DrByte! I'll look forward to trying it when I can regain FTP access to my site (inept current host). I would like to get back into coding enough to keep my hand in, and finish some projects that stalled a few years ago. A couple of them are being demanded by my associates from the festival website.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    I have access to my site (though there are other issues, as it just got hacked, probably through an abandoned wordpress installation, and is still in process of recovery), and find that having these files active causes a blank page. View source has the only output "1". Hiding the config file removes the problem. The only thing I can think of is that it is not calling for the class file at the right breakpoint, but I can't find what that would be. I don't see order.php being instantiated in config.core.php, the way the wiki example showed for cart.php.

    /*Note: 10 has been chosen to cause the observer class to be loaded before the session is started.
    Note: 90 has been chosen as the offset since the observer needs to attach to the $SESSION['cart'] class, which is instantiated at offset 80.
    */

    An offset of 160 did nothing.
    What offset should I use, or is there another way it should be loaded if the order class is not always loaded?

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    BTW, the blank page content isn't "1", it is just blank. The "1" is just the line number. It's been so long since I have viewed page source code that I had forgotten this.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    Quote Originally Posted by gjh42 View Post
    I am working on modifying the order confirmation e-mail to make printable tags for the customer, using the notifiers to avoid editing order.php. (I had previously edited the order.php subject-creation code for admin e-mails to give more useful information on the order content.) My site is www.nyfaeriefest.com, still on v1.5.0, upgraded many times (from v1.3.small?) since 2008. The only relevant parts for this function are order.php and the observer/notifier system.

    I believe I have correctly written the files for using the attribute output to create extra text blocks that customers can print out and bring for ready-made car and tent tags when they arrive at the festival; but there are a few items I am not certain about.

    Code:
    <?php
    /**
     * File contains the car & tent tag building code for confirmation e-mail
     *
     * //@package classes
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @copyright Copyright 2003-2007 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: order_tag_builder.php 2017-03-19 gjh42 $
     */
     
    /*order.php line 795ff
              $sql_data_array = array('orders_id' => $zf_insert_id,
                                      ...
                                      'products_options' => $attributes_values->fields['products_options_name'],
                                      'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      ...
                                      'products_prid' => $this->products[$i]['id']
                                      );
    
              zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
    //called from order class (order.php) by
              $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);
     */
    class orderTagBuilder extends base {
      function __construct() {
        global $zco_notifier;
        $zco_notifier->attach($this, array('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM','NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS'));
        //-------------------------to build tag info---------------------------------------to add tag text to content
      }
    /**
       * Update Method
       * Called by observed class when any of our notifiable events occur
       * @param object $class
       * @param string $eventID
    */
      function update(&$class, $eventID, $paramsArray = array()) {
        if(!is_array($tag_info)) global $tag_info = array();
        if(!isset($tag_qty)) global $tag_qty = 0;
        if($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM') {
          if(in_array($sql_data_array[products_prid, array[7,15,17,18,24,25],true) {//process tag info
            if(!isset(tag_qty)) $tag_qty = 0;
            if(!is_array($tag_info)) $tag_info = array;
            if($sql_data_array[products_options] == 'Name') {
              $tag_info[$tag_qty] .= '<br /><strong>-----------------------------------<br />' . $sql_data_array[products_options_value] . '</strong><br />';
              $tag_qty++;
            }
            if(in_array($sql_data_array[products_options], array['Dates','Onsite phone','Vehicle','Zone preference']) {
              $tag_info[$tag_qty] .= $sql_data_array[products_options] . ': <strong>' . $sql_data_array[products_options_value] . '</strong><br />';
            }
          }
        }
      }//end build tag info
    
    /* called by notify end of product attributes:
        $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS', $custom_insertable_text);
    /* START: ADD MY CUSTOM DETAILS
     * 1. calculate/prepare custom information to be added to this product entry in order-confirmation.
     * 2. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
     *      $this->products_ordered_attributes .=  {INSERT CUSTOM INFORMATION HERE};
     */
      if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
        if(is_array($tag_info)) {//add tags if they exist
          foreach($tag_info[] as $tag_qty,$tag_text) {
            $custom_insertable_text .= '<br /><br /><br />';
            if(strpos($tag_text,'Vehicle') /== false) {//add car tag
              $custom_insertable_text .= '
    <br /><br /><br /><h2><strong>------------------------------------------<br />CAR TAG</strong></h2><br />' . $tag_text . '<br /><br /><br />';
            }
            //add tent tag
            $custom_insertable_text .= '
    <h2><strong>------------------------------------------<br />TENT TAG</strong></h2><br />' . $tag_text . '<br /><br /><br />';
          }
        }
        $this->products_ordered_attributes .=  $custom_insertable_text;//can i do this here?
        unset $tag_info, $tag_qty;//in case the customer wants to make another order
      }//end add tag text to content
    }
    //eof
    Code:
    <?php
    /*
     * //@package autoloaders (In includes/auto_loaders)
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: config.orderTagBuilder.php 2017-03-19 gjh42 $
     */
    
    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/orderTagBuilder.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  'className'=>'orderTagBuilder',
                                  'objectName'=>'orderTagBuilder');
    /*Note: 10 has been chosen to cause the observer class to be loaded before the session is started. 
    Note: 90 has been chosen as the offset since the observer needs to attach to the $SESSION['cart?order?'] class, which is instantiated at offset 80??. 
    */
    //eof
    The code will have to run the tag item code half a dozen separate times for each person in the order, so it needs to remember its previous state.
    if(!is_array($tag_info)) global $tag_info = array();
    if(!isset($tag_qty)) global $tag_qty = 0;
    is intended to do this; is this a good way? Any drawbacks?

    Will
    $zco_notifier->attach($this, array('NOTIFY_ORDER_...
    correctly connect to order.php? This the first time I have actually tried the observer/notifier system. I would have done so in previous mods, but what I needed to do previously required changing stock behavior, not adding new behavior.

    Order.php has notes about using $custom_insertable_text to return such info, but there is no active code in place to append it without editing order.php. I would have no issue with doing that as I have already done so for another purpose, but if it can be avoided, so much the better. Can I update $this->products_ordered_attributes in the observer, or do I have to go back to order.php to do it?

    I will get a testbed set up to try this out, but can't do it right now, so am hoping for some expert guidance in the meantime.

    Recommend using the higher loadpoint (I thought 180ish was recommended, but been a while since I've looked into it) for the class instantiation so that all of the other features of ZC have been loaded such as error logging.

    Below is the code with several comments/discussion. There are some php formatting/typographical errors and then there's some things that as said have been a while since they have been used. Generally speaking looks like if you fix the "grammar" then you might have just what you want.

    Code:
    <?php
    /**
     * File contains the car & tent tag building code for confirmation e-mail
     *
     * //@package classes
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @copyright Copyright 2003-2007 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: order_tag_builder.php 2017-03-19 gjh42 $
     */
     
    /*order.php line 795ff
              $sql_data_array = array('orders_id' => $zf_insert_id,
                                      ...
                                      'products_options' => $attributes_values->fields['products_options_name'],
                                      'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      ...
                                      'products_prid' => $this->products[$i]['id']
                                      );
    
              zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
    //called from order class (order.php) by
              $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);
     */
    class orderTagBuilder extends base {
      function __construct() {
        //global $zco_notifier; // Not needed because have extended base above.
        /*$zco_notifier*/ $this->attach($this,  array('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM','NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS'));
        //-------------------------to build tag info---------------------------------------to add tag text to content
      }
    /**
       * Update Method
       * Called by observed class when any of our notifiable events occur
       * @param object $class
       * @param string $eventID
    */
      function update(&$class, $eventID, $paramsArray = array()) {
        if(!is_array($tag_info)) global $tag_info = array();  // This will execute each time that the update class is loaded and therefore, no history will be maintained for the next load.  Should instead store this variable/data in this class ($this->tag_info) if it is only going to be used herein and needs to be manipulated while this entire thing is being loaded/reused within the same load cycle.
        if(!isset($tag_qty)) global $tag_qty = 0; // Same thing here as one above.
        if($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM') {
          if(in_array($sql_data_array[products_prid, array[7,15,17,18,24,25],true) {/*process tag info //$sql_data_array is not
     defined here, and the code as written is improperly coded (missing a right side square bracket, then also the use of the
     square brackets to define/declare array is incorrect unless a variable has already been somehow declared as array.  
    These should instead be "normal" parentheses such as ().  Then the question of what is truly being sought here, as 
    product data in the order and shopping cart, if an attribute is included, is provided with additional information following 
    the products_id.  So if none of these product have attributes, then you could use the "integers" provided above.  If any 
    do have attributes but the attributes don't matter for the comparison, then something along the lines of what you have 
    kind of work, but the PHP syntax is wrong.  To search if a key is in an array need to use array_key_exists('key', $array) 
    or I believe a variation of array of keys works, but I would check the PHP manual (search on 'php array_key_exists'). If trying to identify if a value is in an array, then yes in_array can work, but it would be: in_array((int)$paramsArray['products_prid'], array(7,15,17,18,24,25)) If you set the last value to true, then your internal array (array(7,15,17...)) as originally written would have required these values to be presented as strings instead of integers.  But, now that the products_prid is being cast to integer, you could keep the last parameter as true if you choose, though it is unnecessary in my opinion.
            if(!isset(tag_qty)) $tag_qty = 0; // unnecessary to check for isset in the current arrangement as it is "set" above.
            if(!is_array($tag_info)) $tag_info = array; // also unnecessary because set above.
            if($sql_data_array[products_options] == 'Name') { // $sql_data_array is not defined within this function.  Perhaps you are wanting to use data that was included in $paramsArray? $sql_data_array got "absorbed" into $paramsArray, so
    if you wanted to get to 'products_options' for this comparison, you would need: if ($paramsArray['products_options'] == 'Name') { //EOL
              $tag_info[$tag_qty] .= '<br  /><strong>-----------------------------------<br />' .  $sql_data_array[products_options_value] . '</strong><br />'; // Again, products_options_value either needs to become a variable $products_options_value or needs to be referenced as a string 'products_options_value'
              $tag_qty++;
            }
            if(in_array($sql_data_array[products_options], array['Dates','Onsite phone','Vehicle','Zone preference']) {
              $tag_info[$tag_qty] .= $sql_data_array[products_options] . ':  <strong>' . $sql_data_array[products_options_value] .  '</strong><br />';
            }
          }
        }
      }//end build tag info
    
    /* called by notify end of product attributes:
        $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS', $custom_insertable_text);
    /* START: ADD MY CUSTOM DETAILS
     * 1. calculate/prepare custom information to be added to this product entry in order-confirmation.
     * 2. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
     *      $this->products_ordered_attributes .=  {INSERT CUSTOM INFORMATION HERE};
     */
      if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
        if(is_array($tag_info)) {//add tags if they exist // This won't be set because once this function is complete, $tag_info falls out of scope... So $tag_info will actually be unset when this notifier is reached during execution.  But, if this class which had been generated earlier in the load stored that value (as discussed in the observer section above), then so long as the entire system hasn't reloaded, this class will still have any values that were maintained... To do this use: $this->tag_info to store/retrieve data associated with this class.
          foreach($tag_info[] as $tag_qty,$tag_text) {
            $custom_insertable_text .= '<br /><br /><br />';
            if(strpos($tag_text,'Vehicle') /== false) {//add car tag The symbol before the double equals should be an exclamation point, not a forward slash, that could be another reason the code has failed to load/500 error.
              $custom_insertable_text .= '
    <br /><br /><br  /><h2><strong>------------------------------------------<br  />CAR TAG</strong></h2><br />' . $tag_text .  '<br /><br /><br />';
            }
            //add tent tag
            $custom_insertable_text .= '
    <h2><strong>------------------------------------------<br  />TENT TAG</strong></h2><br />' . $tag_text .  '<br /><br /><br />';
          }
        }
        $this->products_ordered_attributes .=  $custom_insertable_text;//can i do this here?  // yes if you use $class->products_ordered_attributes, otherwise, as written you are directing to store the data within this class and not passing it back to program flow.
        unset $tag_info, $tag_qty;//in case the customer wants to make another order // This actually is more about clearing memory as in proper program flow, this class should get its values reset when initiated which occurs on a page load, thus if they were to complete a purchase the data associated that is not placed/controlled by a $_SESSION type value will be lost.  Proof? Set a value in one of the header files that won't be loaded at the point of reviewing the result(s). Ie. goto the contact_us header file and add a variable of some type, then go to another header file and echo that variable out.  Then navigate to the contact_us page and then navigate to the page that is supposed to export the value... Not there... Sooo... The unset simply clears the associated memory of those variables which in this situation, there's other factors that could be at play, but basically if I remember scope rules correctly, they will be unset in this function but when going back out of the function they will be as if they never were altered, that might be a specific PHP version situation, I can't recall at the moment, but I also don't unset variables that are intended to be global or reused within the existing code unless I specifically have a test that will reinstate them for reach load in which they would be needed again, which are somewhat done here, but not quite right.... 
      }//end add tag text to content
    }
    //eof
    Code:
    <?php
    /*
     * //@package autoloaders (In includes/auto_loaders)
     * @copyright Copyright 2017 Glenn J. Herbert (gjh42)
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: config.orderTagBuilder.php 2017-03-19 gjh42 $
     */
    
    $autoLoadConfig[10][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/orderTagBuilder.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
                                  'className'=>'orderTagBuilder',
                                  'objectName'=>'orderTagBuilder');
    /*Note: 10 has been chosen to cause the observer class to be loaded before the session is started. 
    Note: 90 has been chosen as the offset since the observer needs to  attach to the $SESSION['cart?order?'] class, which is instantiated at  offset 80??. 
    */
    //eof
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    Thanks for the detailed assessment. This is the first time I have actually tried to use a class, so combined with being away from coding for several years, I needed plenty of pointers :)

  8. #8
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    Quote Originally Posted by gjh42 View Post
    Thanks for the detailed assessment. This is the first time I have actually tried to use a class, so combined with being away from coding for several years, I needed plenty of pointers :)
    No problem, like to help those that try. Valiant effort, and there's possibilities to get where you want with it. Hopefully the comments are helpful in resolving the situation. Could possibly rewrite it if you find that the effort is taking too long/too much, but I also don't like to inhibit one of the important parts of learning: doing. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    This code is only relevant for the given set of product ids, all of which have some or all of the attributes mentioned later. Any other products in the order should be ignored and handed straight back to orders.php instead of looking at their attributes.

    Looking closer at the wiki, I see that the neat example mentioning global $zco_notifier is only for use where the calling code is outside a class... so not used here, as the order class is doing the calling.

    I changed the config file to instantiate at breakpoint 180, as suggested.

    Here is my updated code:
    PHP Code:
    class orderTagBuilder extends base {
      function 
    __construct() {
        
    $this->attach($this, array('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM','NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS'));
        
    //--------------------------^--to build tag info-----------------------------------^--to add tag text to content
      
    }
      
      function 
    update(&$class$eventID$paramsArray = array()) {//$sql_data_array is loaded into $paramsArray
        
    if(!isset($this->tag_qty)) $this->tag_qty 0;
        if(
    $eventID == 'NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM') {
          if(
    in_array($paramsArray[products_prid, array(7,15,17,18,24,25)],true) {//process tag info
            
    if($paramsArray[products_options] == 'Name') {
              
    $this->tag_info[$this->tag_qty] .= '<br /><strong>-----------------------------------<br />' $paramsArray[products_options_value] . '</strong><br />';
              
    $this->tag_qty++;
            }
            if(
    in_array($paramsArray[products_options], array('Dates','Onsite phone','Vehicle','Zone preference')) {
              
    $this->tag_info[$this->tag_qty] .= $paramsArray[products_options] . ': <strong>' $paramsArray[products_options_value] . '</strong><br />';
            }
          }
        }
      }
    //end build tag info

      
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
        if(
    is_array($this->tag_info)) {//add tags if they exist
          
    foreach($this->tag_info[] as $tag_qty_out,$tag_text) {
            
    $custom_insertable_text .= '<br /><br /><br />';
            if(
    strpos($tag_text,'Vehicle') /== false) {//add car tag
              
    $custom_insertable_text .= '
    <br /><br /><br /><h2><strong>------------------------------------------<br />CAR TAG</strong></h2><br />' 
    $tag_text '<br /><br /><br />';
            }
            
    //add tent tag
            
    $custom_insertable_text .= '
    <h2><strong>------------------------------------------<br />TENT TAG</strong></h2><br />' 
    $tag_text '<br /><br /><br />';
          }
        }
        
    $class->products_ordered_attributes .=  $custom_insertable_text;
        unset 
    $this->tag_info$this->tag_qty$tag_qty_out$tag_text;//in case the customer wants to make another order
      
    }//end add tag text to content
    }
    //eof 
    Something is still wrong, as it gives a blank page when activated on the site. I'll look it over again, and another pair of eyes would be appreciated. There are probably a few items I haven't updated to correct usage, like the prid list integer/string bit.

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    I remembered where to find the error logs, and traced the last couple of PHP syntax errors, so it no longer crashes. Now to do a test order and see if and how it works.

    I moved the code from in_array() to array_key_exists().

 

 
Page 1 of 4 123 ... LastLast

Similar Threads

  1. Help customizing Confirmation Email
    By aperfecthost in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 15 Oct 2009, 08:19 PM
  2. Customizing Confirmation Email
    By OLdSalt in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 29 Mar 2009, 01:12 AM
  3. E-mail Text on Confirmation e-mail
    By beth99 in forum General Questions
    Replies: 3
    Last Post: 18 Sep 2006, 02:37 AM

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