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
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
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
In there you will want to text is the current product is the right one . You'll use something like:Code:for ($i=0, $n=sizeof($this->products); $i<$n; $i++) {
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 downCode:if( 100 == $this->products[$i]['id'] ) { // what you want to do goes in here. }
----------------------------
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.
Nick
iszent.com
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?
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
I have included the comment that exists in the original so you can find it.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 */
That just adds a message to that product.
Nick
iszent.com
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
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 */
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?
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.
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
Bookmarks