- Posts: 136
- Thank you received: 1
Emails Not Sending
15 years 6 months ago #11723
by jacorr27
Emails Not Sending was created by jacorr27
Hi Nicolas,
I've modified the order status notification email to include many details from the product, user and order tables.
Although now when I'm testing it appears that the emails are not sent to the user. I can only assume this is due to something I have done with the coding. I have moved a chunk of php code a few lines lower than it was before. Below is a snippet of my code. If I move the PHP code back to where is was then the $data->customer->name; does not return any information. Wondering if you can please shed some light on this?
I would like the emails to be sent to the user, once the status is changed to CONFIRMED.
CODE SNIPPET
<?php
/**
* @package HikaShop for Joomla!
* @version 1.4.5
* @author hikashop.com
* @copyright (C) 2010 HIKARI SOFTWARE. All rights reserved.
* @license www.hikashop.com/commercial_license.php
*/
defined('_JEXEC') or die('Restricted access');
?>
<div style="background-color: #ffffff; font-family: Arial, Helvetica, sans-serif;font-size:12px; color: #000000; width: 100%;">
<table style="margin: auto;font-family: Arial, Helvetica, sans-serif;font-size:12px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="background-color: #cc3232; padding: 5px;"><img src="images/stories/Newsletters/logo.png" border="0" width="220" height="70" /></td>
</tr>
<tr>
<td><br/>
<?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name); ?>
<br/>
<br/>
We are pleased to confirm your Beautyscoop purchase.
<br/>
<br/>
To redeem your Scoop, please print the voucher below and bring into store with you, or gift it to a friend.
<br/>
<br/>
</td>
</tr>
<tr>
<td style background="images/stories/Newsletters/voucher_background2.jpg">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom"><table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Recipient</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php
//displays different Recipient name, based on whether its a gift or not.
$gift = $data->recipient_name;
IF ($gift == ''){
echo "" . $data->customer->name;
}else{
echo "" . $data->recipient_name;
}
?> </td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Voucher #</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $data->order_id; ?></td>
</tr>
<tr><td>
<?php
$class = hikashop::get('class.order');
$url = $data->order_number;
$config =& hikashop::config();
if($config->get('simplified_registration',0)!=2){
$url .= ' ( '.$data->order_url.' )';
}
$data = $class->get($data->order_id);
$data->cart = $class->loadFullOrder($data->order_id,true,false);
$data->cart->coupon = null;
$price = null;
$tax = 0;
foreach($data->cart->products as $product){
$tax+=round($product->order_product_tax,2)*$product->order_product_quantity;
}
$price->price_value = $data->order_full_price-$tax;
$price->price_value_with_tax = $data->order_full_price;
$data->cart->full_total = null;
$data->cart->full_total->prices = array($price);
$data->cart->coupon->discount_value =& $data->order_discount_price;
?>
</td>
</tr>
<tr>
<td valign="top" style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Redeem At</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php
if(hikashop::level(2)){
$fieldsClass = hikashop::get('class.field');
$null = null;
$itemFields = $fieldsClass->getFields('frontcomp',$null,'item');
}
foreach($data->cart->products as $item){
$price = $item->order_product_price*$item->order_product_quantity;
?>
<strong><?php echo $item->order_product_name; ?></strong><?php
if(!empty($itemFields)){
foreach($itemFields as $field){
$namekey = $field->field_namekey;
echo '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey).'</p>';
}
}
echo '<br />';
$productClass = hikashop::get('class.product');
foreach($data->cart->products as $item){
$productData = $productClass->get($item->product_id);
echo $productData->addressline1 ."<br />";
echo $productData->addressline2 ."<br />";
echo "Phone: ".$productData->phone ."<br />";
echo $productData->website;
}
?>
</td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Valid From</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $productData->scoop_start_date; ?></td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Valid To</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $productData->scoop_expiry; ?></td>
</tr>
</table></td>
<td style="text-align:right; height:219;"></td>
</tr>
</table>
END CODE SNIPPET
I've modified the order status notification email to include many details from the product, user and order tables.
Although now when I'm testing it appears that the emails are not sent to the user. I can only assume this is due to something I have done with the coding. I have moved a chunk of php code a few lines lower than it was before. Below is a snippet of my code. If I move the PHP code back to where is was then the $data->customer->name; does not return any information. Wondering if you can please shed some light on this?
I would like the emails to be sent to the user, once the status is changed to CONFIRMED.
CODE SNIPPET
<?php
/**
* @package HikaShop for Joomla!
* @version 1.4.5
* @author hikashop.com
* @copyright (C) 2010 HIKARI SOFTWARE. All rights reserved.
* @license www.hikashop.com/commercial_license.php
*/
defined('_JEXEC') or die('Restricted access');
?>
<div style="background-color: #ffffff; font-family: Arial, Helvetica, sans-serif;font-size:12px; color: #000000; width: 100%;">
<table style="margin: auto;font-family: Arial, Helvetica, sans-serif;font-size:12px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="background-color: #cc3232; padding: 5px;"><img src="images/stories/Newsletters/logo.png" border="0" width="220" height="70" /></td>
</tr>
<tr>
<td><br/>
<?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name); ?>
<br/>
<br/>
We are pleased to confirm your Beautyscoop purchase.
<br/>
<br/>
To redeem your Scoop, please print the voucher below and bring into store with you, or gift it to a friend.
<br/>
<br/>
</td>
</tr>
<tr>
<td style background="images/stories/Newsletters/voucher_background2.jpg">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="bottom"><table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Recipient</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php
//displays different Recipient name, based on whether its a gift or not.
$gift = $data->recipient_name;
IF ($gift == ''){
echo "" . $data->customer->name;
}else{
echo "" . $data->recipient_name;
}
?> </td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Voucher #</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $data->order_id; ?></td>
</tr>
<tr><td>
<?php
$class = hikashop::get('class.order');
$url = $data->order_number;
$config =& hikashop::config();
if($config->get('simplified_registration',0)!=2){
$url .= ' ( '.$data->order_url.' )';
}
$data = $class->get($data->order_id);
$data->cart = $class->loadFullOrder($data->order_id,true,false);
$data->cart->coupon = null;
$price = null;
$tax = 0;
foreach($data->cart->products as $product){
$tax+=round($product->order_product_tax,2)*$product->order_product_quantity;
}
$price->price_value = $data->order_full_price-$tax;
$price->price_value_with_tax = $data->order_full_price;
$data->cart->full_total = null;
$data->cart->full_total->prices = array($price);
$data->cart->coupon->discount_value =& $data->order_discount_price;
?>
</td>
</tr>
<tr>
<td valign="top" style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Redeem At</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php
if(hikashop::level(2)){
$fieldsClass = hikashop::get('class.field');
$null = null;
$itemFields = $fieldsClass->getFields('frontcomp',$null,'item');
}
foreach($data->cart->products as $item){
$price = $item->order_product_price*$item->order_product_quantity;
?>
<strong><?php echo $item->order_product_name; ?></strong><?php
if(!empty($itemFields)){
foreach($itemFields as $field){
$namekey = $field->field_namekey;
echo '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey).'</p>';
}
}
echo '<br />';
$productClass = hikashop::get('class.product');
foreach($data->cart->products as $item){
$productData = $productClass->get($item->product_id);
echo $productData->addressline1 ."<br />";
echo $productData->addressline2 ."<br />";
echo "Phone: ".$productData->phone ."<br />";
echo $productData->website;
}
?>
</td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Valid From</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $productData->scoop_start_date; ?></td>
</tr>
<tr>
<td style="color:#cc3232; font-size:11px; font-weight:bold; text-align: right;">Valid To</td>
<td style="color:#555555; font-size:11px; padding-left:10px;"><?php echo $productData->scoop_expiry; ?></td>
</tr>
</table></td>
<td style="text-align:right; height:219;"></td>
</tr>
</table>
END CODE SNIPPET
Please Log in or Create an account to join the conversation.
15 years 6 months ago #11725
by nicolas
Replied by nicolas on topic Re: Emails Not Sending
On the line:
$data = $class->get($data->order_id);
the $data object gets the whole order object from the database. So you need that code to be before something like this:
echo "" . $data->recipient_name;
However, the subobject customer is in the $data before loading the email. After the line $data = $class->get($data->order_id); the customer subobject is not there anymore.
So that's probably why, when you move code around, you don't always get the values of what you want.
Concerning the fact that the email is not sending, do you have some kind of error ?
$data = $class->get($data->order_id);
the $data object gets the whole order object from the database. So you need that code to be before something like this:
echo "" . $data->recipient_name;
However, the subobject customer is in the $data before loading the email. After the line $data = $class->get($data->order_id); the customer subobject is not there anymore.
So that's probably why, when you move code around, you don't always get the values of what you want.
Concerning the fact that the email is not sending, do you have some kind of error ?
Please Log in or Create an account to join the conversation.
15 years 6 months ago #11728
by jacorr27
Replied by jacorr27 on topic Re: Emails Not Sending
But that's confusing me because the php code is exactly the same as the original email it's just moved a few lines down. Because of the fact that the user name wasn't displaying anywhere underneath that chunk of code.
I searched for $data = $class->get($data->order_id); in the original notification - before I made any changes and I don't see the subobject you're referring to.
Can't see any errors either.
This is the last piece of work before my site goes live! I'm incredibly happy with this product and support.
I searched for $data = $class->get($data->order_id); in the original notification - before I made any changes and I don't see the subobject you're referring to.
Can't see any errors either.
This is the last piece of work before my site goes live! I'm incredibly happy with this product and support.
Please Log in or Create an account to join the conversation.
15 years 6 months ago #11730
by jacorr27
Replied by jacorr27 on topic Re: Emails Not Sending
Hi Nicolas,
Where can I see if there are any errors relating to the emails not being delivered?
Thank you,
jac
Where can I see if there are any errors relating to the emails not being delivered?
Thank you,
jac
Please Log in or Create an account to join the conversation.
15 years 6 months ago #11742
by nicolas
Replied by nicolas on topic Re: Emails Not Sending
You can try to change the status of an order in your back end and activate the notification. If you have an error it should be displayed in the popup.
Please Log in or Create an account to join the conversation.
15 years 6 months ago #11752
by jacorr27
Replied by jacorr27 on topic Re: Emails Not Sending
Hi Nicolas,
I just replied to another thread relating to the same problem.
I have been testing through the status change, and receiving no errors.
Jac
I just replied to another thread relating to the same problem.
I have been testing through the status change, and receiving no errors.
Jac
Please Log in or Create an account to join the conversation.
Time to create page: 0.166 seconds