Order Status Email Query

  • Posts: 377
  • Thank you received: 7
12 years 1 day ago #76715

Hi,

I am trying to get the order status email to include the product description also. I have managed to get it to include the first description of the first product ordered ok but if the customer orders more than one item it doesn't include the description from the second item below the description of the first item...

Below is the code I am using for the email and also attached is how the email comes out...

<?php
/**
 * @package    HikaShop for Joomla!
 * @version    1.6.0
 * @author    hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<div style="background-color: #ffffff; font-size: 100%; font-family: Tahoma,Geneva,Kalimati,sans-serif; color: #8a8a8a; width: 100%;">
  <table style="margin: auto; width: 560px;" border="0" cellspacing="0" cellpadding="0">
    <tbody>
      <tr>
        <td height="10">
        </td>
      </tr>
      <tr>
        <td style="background-color: #333; font-color:white; font-weight:bold; color:white;padding:0px; text-align:center; font-size:12px; font-family:Arial, Helvetica, sans-serif;">
        <img src="http://www.liveelite.co.uk/images/email/live-elite-voucher.jpg" alt="Live Elite Voucher" width="560" height="116" /><p style="font-weight:bold; font-size:18px; color:#fff;">
          <?php
          $order_url = $data->order_url;
          $mail_status = $data->mail_status;
          $customer = $data->customer;
          $order_status = $data->order_status;
          $class = hikashop_get('class.order');
          $data = $class->get($data->order_id);
          $url = $data->order_number;
          $data->order_url = $order_url;
          $data->order_status = $order_status;
          $data->mail_status = $mail_status;
          $config =& hikashop_config();
          if($config->get('simplified_registration',0)!=2){
            $url = ''. $url.'';
          }
          echo JText::sprintf('HI_CUSTOMER',@$customer->name);?>
          <br/>
          <br/>
       
          <?php
          echo JText::sprintf('ORDER_STATUS_CHANGED_TO',$url,$data->mail_status);
          $data->cart = $class->loadFullOrder($data->order_id,true,false);
          $data->cart->coupon = null;
          $price = null;
          $tax = $data->cart->order_subtotal - $data->cart->order_subtotal_no_vat + $data->order_discount_tax + $data->order_shipping_tax;
          $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;
          $app=&JFactory::getApplication();
          if($app->isAdmin()){
            $view = 'order';
          }else{
            $view = 'address';
          }
          $colspan = 4;
          ?>
</p>
        <p style="font-weight:bold; font-size:18px; color:#fff;"> </p>
        </p></td>
      </tr>
      <tr>
        <td>
          <h1 style="background-color:#000;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">DEAL INFORMATION</h1>
         
          <table width="100%" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;">
            <tr>
              <td style="font-weight:bold; font-family:Arial, Helvetica, sans-serif;">
                <?php echo JText::_('CART_PRODUCT_NAME'); ?>
              </td>
              <?php if ($config->get('show_code')) { $colspan++; ?>
                <td style="font-weight:bold; font-family:Arial, Helvetica, sans-serif;"><?php echo JText::_('CART_PRODUCT_CODE'); ?></td>
              <?php } ?>
              <td style="font-weight:bold; font-family:Arial, Helvetica, sans-serif;">
                <?php echo JText::_('CART_PRODUCT_UNIT_PRICE'); ?>
              </td>
              <td style="font-weight:bold; font-family:Arial, Helvetica, sans-serif;">
                <?php echo JText::_('CART_PRODUCT_QUANTITY'); ?>
              </td>
              <td style="font-weight:bold;font-family:Arial, Helvetica, sans-serif; text-align:right;">
                <?php echo JText::_('HIKASHOP_TOTAL'); ?>
              </td>
            </tr>
            <?php
              if(hikashop_level(2)){
                $fieldsClass = hikashop_get('class.field');
                $null = null;
                $itemFields = $fieldsClass->getFields('frontcomp',$null,'item');
              }
              $group = $config->get('group_options',0);
              foreach($data->cart->products as $item){
                if($group && $item->order_product_option_parent_id) continue;
                ?>
                <tr>
                  <td>
                    <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">
                      <?php echo $item->order_product_name;
                      if($group){
                        $display_item_price=false;
                        foreach($data->cart->products as $j => $optionElement){
                          if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if($optionElement->order_product_price>0){
                            $display_item_price = true;
                          }
                        }
                        if($display_item_price){
                          if($config->get('price_with_tax')){
                            echo ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                          }else{
                            echo ' '.$currencyHelper->format($item->order_product_price,$data->order_currency_id);
                          }
                        }
                      } ?>
                    </p><?php
                    if(!empty($itemFields)){
                      foreach($itemFields as $field){
                        $namekey = $field->field_namekey;
                        if(empty($item->$namekey)) continue;
                        echo '<p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey).'</p>';
                      }
                    }
                    if($group){
                      foreach($data->cart->products as $j => $optionElement){
                        if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                        $item->order_product_price +=$optionElement->order_product_price;
                        $item->order_product_tax +=$optionElement->order_product_tax;
                        $item->order_product_total_price+=$optionElement->order_product_total_price;
                        $item->order_product_total_price_no_vat+=$optionElement->order_product_total_price_no_vat;
                         ?>
                          <p class="hikashop_order_option_name" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">
                            <?php
                              echo $optionElement->order_product_name;
                              if($optionElement->order_product_price>0){
                                if($config->get('price_with_tax')){
                                  echo ' ( + '.$currencyHelper->format($optionElement->order_product_price+$optionElement->order_product_tax,$data->order_currency_id).' )';
                                }else{
                                  echo ' ( + '.$currencyHelper->format($optionElement->order_product_price,$data->order_currency_id).' )';
                                }
                              }
                            ?>
                          </p>
                      <?php
                      }
                    }
                    $statusDownload = explode(',',$config->get('order_status_for_download','confirmed,shipped'));
                    if(!empty($item->files) && in_array($data->order_status,$statusDownload)){
                      global $Itemid;
                      $url_itemid = '';
                      if(!empty($Itemid)){
                        $url_itemid='&Itemid='.$Itemid;
                      }
                      echo '<p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">';
                      foreach($item->files as $file){
                        $fileName = empty($file->file_name) ? $file->file_path : $file->file_name;
                        echo '<a href="'.hikashop_frontendLink('index.php?option=com_hikashop&ctrl=order&task=download&file_id='.$file->file_id.'&order_id='.$data->order_id.$url_itemid).'">'.$fileName.'</a><br/>';
                      }
                      echo '</p>';
                    }
                    ?>
                  </td>
                  <?php if ($config->get('show_code')) { ?>
                    <td><p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;" class="hikashop_product_code_mail"><?php echo $item->order_product_code; ?></p></td>
                  <?php } ?>
                  <td>
                    <?php
                    if($config->get('price_with_tax')){
                      echo $currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                    }else{
                      echo $currencyHelper->format($item->order_product_price,$data->order_currency_id);
                    } ?>
                  </td>
                  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">
                    <?php echo $item->order_product_quantity; ?>
                  </td>
                  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;text-align:right">
                    <?php
                    if($config->get('price_with_tax')){
                      echo $currencyHelper->format($item->order_product_total_price,$data->order_currency_id);
                    }else{
                      echo $currencyHelper->format($item->order_product_total_price_no_vat,$data->order_currency_id);
                    } ?>
                  </td>
                </tr>
                <?php
              }
              if(bccomp($data->order_discount_price,0,5)){
                echo '<tr style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;"><td colspan="'.$colspan.'" style="text-align:right">'.JText::_('HIKASHOP_COUPON').' : ';
                if($config->get('price_with_tax')){
                  echo $currencyHelper->format($data->order_discount_price*-1,$data->order_currency_id);
                }else{
                  echo $currencyHelper->format(($data->order_discount_price-@$data->order_discount_tax)*-1,$data->order_currency_id);
                }
                echo '</td></tr>';
              }
              if(bccomp($data->order_shipping_price,0,5)){
                echo '<tr><td colspan="'.$colspan.'"style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;text-align:right">'.JText::_('HIKASHOP_SHIPPING_METHOD').' : ';
                if($config->get('price_with_tax')){
                  echo $currencyHelper->format($data->order_shipping_price,$data->order_currency_id);
                }else{
                  echo $currencyHelper->format($data->order_shipping_price-@$data->order_shipping_tax,$data->order_currency_id);
                }
                echo '</td></tr>';
              }
              if(bccomp($data->order_payment_price,0,5)){
                echo '<tr><td colspan="'.$colspan.'" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; text-align:right">'.JText::_('HIKASHOP_PAYMENT_METHOD').' : '.$currencyHelper->format($data->order_payment_price,$data->order_currency_id).'</td></tr>';
              }
              if(!empty($data->cart->additional)) {
                $exclude_additionnal = explode(',', $config->get('order_additional_hide', ''));
                foreach($data->cart->additional as $additional) {
                  if(in_array($additional->name, $exclude_additionnal)) continue;
                  echo '<tr><td colspan="'.$colspan.'"style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; text-align:right">'. JText::_($additional->order_product_name).' : ';
                  if(!empty($additional->order_product_price) || empty($additionaltionnal->order_product_options)) {
                    if($config->get('price_with_tax')){
                      echo $currencyHelper->format($additional->order_product_price+@$additional->order_product_tax, $data->order_currency_id);
                    }else{
                      echo $currencyHelper->format($additional->order_product_price, $data->order_currency_id);
                    }
                  } else {
                    echo $additional->order_product_options;
                  }
                  echo '</td></tr>';
                }
              }
              if($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax){
                if($config->get('detailed_tax_display') && !empty($data->cart->order_tax_info)){
                  foreach($data->cart->order_tax_info as $tax){
                    echo '<tr><td colspan="'.$colspan.'" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; text-align:right">'.$tax->tax_namekey. ' : '.$currencyHelper->format($tax->tax_amount,$data->order_currency_id).'</td></tr>';
                  }
                }else{
                  echo '<tr><td colspan="'.$colspan.'" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; text-align:right">'.JText::sprintf('TOTAL_WITHOUT_VAT',$currencyHelper->format($data->cart->full_total->prices[0]->price_value,$data->order_currency_id)).'</td></tr>';
                }
                $text=JText::sprintf('TOTAL_WITH_VAT',$currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->order_currency_id));
              }else{
                $text=JText::_('HIKASHOP_FINAL_TOTAL'). ' : '.$currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->order_currency_id);
              }
              echo '<tr><td colspan="'.$colspan.'" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; text-align:right;font-weight:bold;">'.$text.'</td></tr>';
              ?>
          </table>
        </td>
      </tr>
      <tr>
        <td height="10">          <h1 style="background-color:#000;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">DETAILS / T&C's / HOW TO REDEEM</h1>
                            <?php $productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->product_description; ?>
        </td>
      </tr>
      <tr>
        <td>
  <!--        <table width="100%" style="border: 1px solid #DDDDDD;font-family:Arial, Helvetica, sans-serif;font-size:12px;">
          <?php
          $params = null;
          $js = '';
          $fieldsClass = hikashop_get('class.field');
          $template = trim(hikashop_getLayout($view,'address_template',$params,$js));
          if(!empty($data->cart->billing_address)){
            $billing = $template;
            foreach($data->cart->fields as $field){
              $fieldname = $field->field_namekey;
              $billing=str_replace('{'.$fieldname.'}',$fieldsClass->show($field,$data->cart->billing_address->$fieldname),$billing);
            }
            echo '<tr><td style="font-weight:bold; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">'.JText::_('HIKASHOP_BILLING_ADDRESS').'</td></tr><tr><td>';
            echo str_replace(array("\r\n","\r","\n"),'<br/>',preg_replace('#{(?:(?!}).)*}#i','',$billing)).'<br/></td></tr>';
          }
          if(!empty($data->cart->override_shipping_address)) {
            echo '<tr><td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; font-weight:bold;background-color:#DDDDDD">'.JText::_('HIKASHOP_SHIPPING_ADDRESS').'</td></tr><tr><td>';
            echo $data->cart->override_shipping_address.'<br/></td></tr>';
          } elseif(!empty($data->order_shipping_id) && !empty($data->cart->shipping_address)){
            $shipping = $template;
            foreach($data->cart->fields as $field){
              $fieldname = $field->field_namekey;
              $shipping=str_replace('{'.$fieldname.'}',$fieldsClass->show($field,$data->cart->shipping_address->$fieldname),$shipping);
            }
            echo '<tr><td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; font-weight:bold;background-color:#DDDDDD">'.JText::_('HIKASHOP_SHIPPING_ADDRESS').'</td></tr><tr><td>';
            echo str_replace(array("\r\n","\r","\n"),'<br/>',preg_replace('#{(?:(?!}).)*}#i','',$shipping)).'<br/></td></tr>';
          }?>
          </table> -->
        </td>
      </tr>
      <tr>
        <td>
          <?php
          $fields = $fieldsClass->getFields('frontcomp',$data,'order','');
          foreach($fields as $fieldName => $oneExtraField) {
            if(empty($data->$fieldName)) continue;
            echo "<br/>".$fieldsClass->trans($oneExtraField->field_realname).' : '.$fieldsClass->show($oneExtraField,$data->$fieldName);
          } ?>
        </td>
      </tr>
<?php
  JPluginHelper::importPlugin('hikashop');
  $dispatcher =& JDispatcher::getInstance();
  $dispatcher->trigger('onAfterOrderProductsListingDisplay', array(&$data->cart, 'email_notification_html'));
?>
      <tr>
        <td height="10">
        </td>
      </tr>
      <tr>
        <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333;">
          <?php echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER',HIKASHOP_LIVE);?>
          <br/>
          <br/>
          Kind Regards, Live Elite
        </td>
      </tr>
      <tr>
        <td height="10" style="background-color: #ffffff;">
        </td>
      </tr>
      <tr>
        <td height="10"><h1 style="background-color:#000;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff;"><a style="color:#fff; text-decoration:none; font-family:Arial, Helvetica, sans-serif;"href="http://www.liveelite.co.uk" target="_blank">WWW.LIVEELITE.CO.UK</a></h1>
        </td>
      </tr>
    </tbody>
  </table>
</div>
<?php $data->customer = $customer;?>

Attachments:
Last edit: 12 years 14 hours ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 26152
  • Thank you received: 4027
  • MODERATOR
12 years 14 hours ago #76838

Hi,

You're not making a loop on all items in the cart.
Replace your code

<h1 style="background-color:#000;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">DETAILS / T&C's / HOW TO REDEEM</h1>
<?php $productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->product_description; ?>
By
<h1 style="background-color:#000;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">DETAILS / T&C's / HOW TO REDEEM</h1>
<?php
foreach($data->cart->products as $item){
  echo $item->product_description.'<br/>';
}
?>
It should works.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
12 years 6 hours ago #76912

Thanks Jerome for your help, unfortunately when replacing the code you mentioned nothing shows up at all when the email is produced. Please see attached. Any ideas?

Thanks,

Alex

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 hours ago #76982

Hi,

Can you try with "echo $item->order_product_description.'<br/>';" instead of "echo $item->product_description.'<br/>';".

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 11 months ago #77076

Hi Xavier,

Still no luck with changing that to the suggested code.. the table is just still coming up blank :S

Thanks

Alex

Please Log in or Create an account to join the conversation.

  • Posts: 26152
  • Thank you received: 4027
  • MODERATOR
11 years 11 months ago #77106

Hi,

So the product description is not loaded in the cart object.
It's not a big problem :)

<?php
$productClass = hikashop_get('class.product');
foreach($data->cart->products as $item){
   $product = $productClass->get($item->product_id);
   echo $product->product_description.'<br/>';
}

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: Dibben

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 11 months ago #77218

That's working just great thanks!

Kind regards

Alex

Please Log in or Create an account to join the conversation.

Time to create page: 0.063 seconds
Powered by Kunena Forum