Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Send additional order confirmation email based on product ordered.

    I would like to send an additional order confirmation email to the purchaser with password information (based on the product purchased). How do I code order.php? ...and do I also have to change the email template?
    Thank you!!!
    Cindy Weber

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Send additional order confirmation email based on product ordered.

    Well, that is quite a big question and has a few parts.

    But you are in the right place. order.php is where the work will get done.

    -----------------------------

    Firstly, have you created the password already? If not then that is a whole different subject.

    -----------------------------

    You need to check that that particular product has been ordered. You'll do that in the 'for' statement that loops through all the products. It starts with this line at about 696

    Code:
        for ($i=0, $n=sizeof($this->products); $i<$n; $i++) {
    In there you will want to text is the current product is the right one . You'll use something like:

    Code:
    if( 100 == $this->products[$i]['id'] )
    {
      // what you want to do goes in here.
    }
    That would test if the product is id=100 and then do something. I am writing the code off the top of my head so there may be typos in there :-) You can put that pretty much anywhere in the 'for' loop but see what I say lower down

    ----------------------------

    Now for what you actually want to do. Well that is kind of up to you. But you can either send a separate email or add the information to the existing email.

    To send a separate email look at the function zen_mail and have a look at how it is used on line 1050ish of order.php.

    To add the information to the existing email you'd add the string to the $custom_information. There are some comments about how to do that at about line 880 of order.php.

    --------------------------

    Hope that all helps. It is hard to comment further without more information.

  3. #3
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Re: Send additional order confirmation email based on product ordered.

    Niccol:
    Thank you for your response!!
    I attempted to add it to the existing email. The email is still functioning, but it does not show up in the email. I am using an elseif statement. It starts on line 985 with:
    if($this->products[$i]['id'] = '4') {

    // build output for email notification
    $this->products_ordered .= $this->products[$i]['qty'] . ' x ' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') . ' = ' .
    $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) ;

    if($this->products[$i]['id'] = '4') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: 90 Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '2') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: 90 Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '7') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: 45 Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '3') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: 45 Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '8') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: abc Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '9') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: abc Password: student (the word student, not your name)';
    }
    elseif($this->products[$i]['id'] = '6') {
    $this->products_ordered_attributes .= "\n" . 'Link: link User Name: abc Password: student (the word student, not your name)';
    }

    ($this->products[$i]['onetime_charges'] !=0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') .

    What am I doing wrong?

  4. #4
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Send additional order confirmation email based on product ordered.

    Well the version of order.php that I am working on is a bit different so the line numbers do not match up :-) but the easiest way of doing that is about line 896

    Code:
            if( 100==$this->products[$i]['id'] )
            {
            $custom_insertable_text .= 'A MESSAGE HERE';
            }
    
            $this->products_ordered_attributes .= $custom_insertable_text;
    
    /* END: ADD MY CUSTOM DETAILS */
    I have included the comment that exists in the original so you can find it.

    That just adds a message to that product.

  5. #5
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Re: Send additional order confirmation email based on product ordered.

    Thank you again!! What if I have multiple products? The form still works without error but nothing still shows in my email.

    * $this->products_ordered_attributes .= {INSERT CUSTOM INFORMATION HERE};
    */
    if( 4==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: 90 Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 2==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: 90 Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 7==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: 45 Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 3==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: 45 Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 8==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: abc Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 9==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: abc Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    elseif( 6==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: abc Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    /* END: ADD MY CUSTOM DETAILS */

    Am I missing an initial statement?
    Thanks again!
    Cindy

  6. #6
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Re: Send additional order confirmation email based on product ordered.

    I just tried it without the elseif's, and it still doesn't show on the confirmation email. Would the settings....plain text v html....make a difference here? I have it set for html, put I see plain text. Here is the 1 item version, in context, starting with if.

    * $this->products_ordered_attributes .= {INSERT CUSTOM INFORMATION HERE};
    */
    if( 4==$this->products[$i]['id'] )
    {
    $custom_insertable_text .= 'Link: User Name: 90 Password: student (the word student, not your name)';
    }
    $this->products_ordered_attributes .= $custom_insertable_text;
    /* END: ADD MY CUSTOM DETAILS */

  7. #7
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Re: Send additional order confirmation email based on product ordered.

    I am still trying.

    This is my error:
    PHP Fatal error: Cannot use string offset as an array in includes/classes/order.php on line 985
    v1.3.9h

    line 982 // build output for email notification
    $this->products_ordered .= $this->products[$i]['qty'] . ' x ' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') . ' = ' .
    $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) ;
    line 985 if ($this->products_ordered[$i]['id'] =='4'.
    $this->products_ordered_attributes .= "\n" . "User Name: 90 Password: student");
    elseif
    ($this->products_ordered[$i]['id'] == '2'.
    $this->products_ordered_attributes .= "\n" . "User Name: 90 Password: student");
    elseif
    ($this->products[$i]['id'] == '7'.
    $this->products_ordered_attributes .= "\n" . "User Name: 45 Password: student");
    elseif
    ($this->products_ordered[$i]['id'] == '3'.
    $this->products_ordered_attributes .= "\n" . "User Name: 45 Password: student");
    elseif
    ($this->products_ordered[$i]['id'] == '8'.
    $this->products_ordered_attributes .= "\n" . "User Name: abc Password: student");
    elseif
    ($this->products_ordered[$i]['id'] = '9'.
    $this->products_ordered_attributes .= "\n" . "User Name: abc Password: student ");
    elseif
    ($this->products_ordered[$i]['id'] == '6'.
    $this->products_ordered_attributes .= "\n" . "User Name: abc Password: student");

    END ($this->products[$i]['onetime_charges'] !=0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') .
    $this->products_ordered_attributes . "\n";
    $this->products_ordered_html .=

    Can anyone help?

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

    Default Re: Send additional order confirmation email based on product ordered.

    line 985 if ($this->products_ordered[$i]['id'] =='4'.
    should probably be
    line 985 if ($this->products[$i]['id'] =='4'.
    .

    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.

  9. #9
    Join Date
    Feb 2012
    Posts
    68
    Plugin Contributions
    0

    Default Re: Send additional order confirmation email based on product ordered.

    Thank you for the quick response! That worked! The error's gone, but it still doesn't show in the confirmation email. Here is the email.

    Thanks for shopping with us today!
    The following are the details of your order.
    ------------------------------------------------------
    Date Ordered: Tuesday 20 March, 2012
    Products
    ------------------------------------------------------
    1 x 90 hour Principles, Practices and Law Hard-Copy Course =
    $0.01------------------------------------------------------
    Sub-Total: $0.01
    Total: $0.01

    Delivery Address

 

 

Similar Threads

  1. Order confirmation email recipients based on product purchased
    By LegionSmith in forum General Questions
    Replies: 15
    Last Post: 2 Oct 2010, 02:00 PM
  2. Replies: 0
    Last Post: 6 Oct 2009, 05:15 PM
  3. Trying to send unique e-mails based on product ordered
    By Greg Dean in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 12 May 2009, 11:55 PM
  4. Send additional order confirmation email help
    By imageriot in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 12 Mar 2008, 01:05 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