Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 34
  1. #11
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Customizing confirmation e-mail

    The code gives no errors when processing an order, but no results either. At this point I am stumped, as I have added tracer output that should add a bit to the e-mail output no matter how well the code works, as long as the update method fires at all and $class->products_ordered_attributes is able to be updated from the method.
    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) {//$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'))) {//process tag info
            
    if($paramsArray['products_options'] == 'Name') {
              
    $this->tag_info[$this->tag_qty] .= '<br /><strong>-----------------------------------<br />' $paramsArray['products_options_values'] . '</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_values'] . '</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 />';
            }
          }
            
    $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          
    $class->products_ordered_attributes .=  $custom_insertable_text ' <br />testing text output.<br /> ';//debug
          
    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
        
    $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      
    }// /update
    }
    //eof 

  2. #12
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Customizing confirmation e-mail

    I haven't seen anything that "stands out" as to why the information isn't being added, but did question this statement:
    Code:
     if(strpos($tag_text,'Vehicle') /== false) {//add car tag
    Shouldn't that be
    Code:
     if(strpos($tag_text,'Vehicle') !== false) {//add car tag
    Also, the line that reads
    Code:
    foreach($this->tag_info[] as $tag_qty_out,$tag_text) {
    should be, I believe:
    Code:
    foreach($this->tag_info as $tag_qty_out => $tag_text) {
    Last edited by lat9; 2 Apr 2017 at 06:17 PM.

  3. #13
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    This line became better through iterations, but if the product has the possibility of having attributes, then something more needs to be done. Comes down to if it doesn't matter what attributes the product has and want to take action just because of the product then need to trim down the mixed variable (key) products_prid to just the number/string that represents the product by itself and without the additional hashing.

    So from:
    Code:
    if(in_array($paramsArray['products_prid'],##array('7','15','17','18','24','25')))##{//process##tag##info
    To:
    Code:
    if(in_array((int)$paramsArray['products_prid'],##array(7,15,17,18,24,25)))##{//process##tag##info
    Then, while not an error yet, would recommend declaring the variables that are to be internally tracked. Would say that this would be done within the __construct. Ie. The array does not appear to be identified that it will be an array. In newer php versions, that becomes an issue. It also makes things a little clearer for coding purposes.

    As part of that "declaration" to go ahead and claim the variables as part of the class (just after the class is declared but before the construction function.) at that point, they are not referenced as $this->variable but instead just $variable.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Customizing confirmation e-mail

    Lat9 - Oops, a couple of dumb errors that I blame on being out of practice...

    Mc - The code wants to be executed whenever one of the given product ids is present. They will always have attributes, but it doesn't matter here which ones are present.
    So the variables should be declared just below the class() line with var or whatever, then initialized in the construct method.

  5. #15
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    Code example I gave with casting with (int) will ensure to compare product number to product number and "ignore" the associated attributes.

    As to the variable declaration, agree so much as understand to myself the words used, but would have to see it to know if we were on the same page. Regardless a "style" at the moment, not so much a necessity for the code to work on your system. The couple of other things pointed out would be more of what is needed for it to work as expected.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Customizing confirmation e-mail

    I researched class variable ("property") instantiation to know the full rules... So it looks like there are options; I chose to instantiate in the class declaration, as the initial values are all simple.
    PHP Code:
    class orderTagBuilder extends base {
      public 
    $tag_info = array();
      public 
    $tag_qty 0;
      public 
    $tag_formatted ''
    The ZC wiki examples I initially worked from are pretty old, and used the "var" syntax.

    But the code still doesn't do anything visible in the e-mail. I can't think of anything else to do to prove that the update method is actually being fired in the first place. V1.5.0 has the order class with notifiers, though they are all in the form of

    $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);

    Does this affect the way the constructor should be written?

    'products_prid' will only ever contain a single number as its value; all attribute info is in other variables.
    PHP Code:
                                      'products_options' => $attributes_values->fields['products_options_name'],
                                      
    'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      ...
                                      
    'products_prid' => $this->products[$i]['id'

  7. #17
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    Quote Originally Posted by gjh42 View Post
    I researched class variable ("property") instantiation to know the full rules... So it looks like there are options; I chose to instantiate in the class declaration, as the initial values are all simple.
    PHP Code:
    class orderTagBuilder extends base {
      public 
    $tag_info = array();
      public 
    $tag_qty 0;
      public 
    $tag_formatted ''
    The ZC wiki examples I initially worked from are pretty old, and used the "var" syntax.

    But the code still doesn't do anything visible in the e-mail. I can't think of anything else to do to prove that the update method is actually being fired in the first place. V1.5.0 has the order class with notifiers, though they are all in the form of

    $zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);

    Does this affect the way the constructor should be written?

    'products_prid' will only ever contain a single number as its value; all attribute info is in other variables.
    PHP Code:
                                      'products_options' => $attributes_values->fields['products_options_name'],
                                      
    'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      ...
                                      
    'products_prid' => $this->products[$i]['id'
    Add one of your attribute products to the cart where you have selected one or more attributes... Now go to the cart and either click on the product's name which should take you back to the product with all of the selections "enabled" or just simply look at the uri that is generated (assuming not a URI rewriter that modifies the uri significantly)... What is the products_id that you see at the end? Is it just a number? Have you also followed to see how 'id' has been generated in the above array data or how it is otherwise used? The only time that it is a single "number" is if there are no attributes associated with it, or if there are modifications made on the admin side where the admin's version of zen_get_uprid function is used which works differently than the store side.

    Here's an output of session data after adding a ZC sample product to the shopping cart Product 78, notice the 'id'... It's not a number only.. if you want a ZC function that accomplishes the same thing as casting to an integer, then you can use zen_get_prid($variable) where $variable is a mixed value of a string made up of a number followed by a colon followed by the attributes as hashed together. By casting to an integer, everything that is at or after the colon is dropped:

    Code:
                [id] => 78:070c7306cc246083d5ddd6c5d5541abd             [category] => 25             [name] => TEST 25% special 10% Sale Attribute Priced             [model] => Test25-10AttrAll             [image] => test_demo.jpg             [price] => 0.0000             [quantity] => 1             [weight] => 0             [final_price] => 150             [onetime_charges] => 0             [tax_class_id] => 1             [attributes] => Array                 (                     [1] => 16                     [2] => 21                     [13_chk36] => 36                 )              [attributes_values] =>              [products_priced_by_attribute] => 1             [product_is_free] => 0             [products_discount_type] => 0             [products_discount_type_from] => 0             [products_virtual] => 0             [product_is_always_free_shipping] => 0         )
    The basis of your routine is that product is in the cart that needs additional information... If nothing is detected, then little to nothing will happen. As to firing or not, I would check/verify that your auto_loader file(s) are correct/well.. I realize you chose 10 and 180 as firing points, I use 0 and typically 180+ though the second one somewhat just depends... Anyways, if the file is not being called then it doesn't matter about the rest. Put an echo in the beginning of the file and see if it tries to export...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #18
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Customizing confirmation e-mail

    Just noticed something in the following section:
    Code:
    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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update
    The code is attempting to set the $custom_insertable_text value that's initially defined in the order-class, so a global statement needs to be used to identify that variable's scope:
    Code:
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
          global $custom_insertable_text;
          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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update

  9. #19
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Customizing confirmation e-mail

    Quote Originally Posted by lat9 View Post
    Just noticed something in the following section:
    Code:
    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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update
    The code is attempting to set the $custom_insertable_text value that's initially defined in the order-class, so a global statement needs to be used to identify that variable's scope:
    Code:
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
          global $custom_insertable_text;
          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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update
    That won't improve the situation because $custom_insertable_text is defined within the calling function and is not made global. Further, if the text that exists up to that point within $custom_insertable_text is added within this function, then it will again be added when the notifier returns. This notifier: NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS provides the inmutable version of the variable within $paramsArray not as an array but as a variable. If it is desired to have that text appended twice, then go ahead and collect it in the above section of NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS; however, in absence of collecting that, technically $custom_insertable_text should be established to be empty at the onset of that area of code to be used within to add to $this->products_ordered_attributes ($class->products_ordered_attributes) before the pre-existing $custom_insertable_text or to be added before any other $custom_insertable_text that is within that function after the notifier NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS and before the assignment of $this->products_ordered_attributes .= $custom_insertable_text.

    In other words, because no error messages have been generated in running this code, the attempt within the above code to append new text to an undefined variable were not corrected by me at least because of this "loop-hole" in the notifier/observer system that existed until ZC 1.5.3 where the $custom_insertable_text was made malleable.

    So, again if it is desired to use the pre-existing $custom_insertable_text within this function and to then have it appended to the end of this work the code in this area would be:

    Code:
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
          $custom_insertable_text = $paramsArray;
          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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text  . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update
    For $custom_insertable_text to be allowed to be added after this text:
    Code:
    if ($eventID == 'NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS') {
          $custom_insertable_text = '';
          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 />';
            }
          }
            $custom_insertable_text .= ' <br />testing output.<br /> ';//debug
          $class->products_ordered_attributes .=  $custom_insertable_text  . ' <br />testing text output.<br /> ';//debug
          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
        $class->products_ordered_attributes .=  ' <br />testing text output - method run.<br /> ';//debug
      }// /update
    There is no way at this time, without listening to another notifier after NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS, to add the new text after the existing assignment of $custom_insertable_text, but then again run the "risk" of double capturing the $custom_insertable_text in the result. The next notifier available is: NOTIFY_ORDER_PROCESSING_ONE_TIME_CHARGES_BEGIN at which the internal data captured by the above code (requiring modification to maintain the data internal) could then be added to the $class->products_ordered_attributes.
    Last edited by mc12345678; 3 Apr 2017 at 02:42 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #20
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Customizing confirmation e-mail

    You're right, mc12345678, declaring that value global doesn't do the trick.

    I'll also point out that Zen Cart 1.5.0, which appears (?) to be the version that @gjh42 is using, doesn't have the notifier support for "modifiable" parameters.

 

 
Page 2 of 4 FirstFirst 1234 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