description not showing in email or pdf variants

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166408

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.0
-- PHP version -- : 5.4
-- Error-message(debug-mod must be tuned on) -- : Product description not showing in email when product has variants

Hi,
I have this code for the emails that shows the product description in the email when the customer buys a product. However when the product has a variant this doesn't show. Do you know why this would be? Do i need to add the description to each variant also?

<!-- {terms and conditions info} -->
                          
                                   <table width="100%" border="0">
  <tr>
             <td>         <h1 style="background-color:#333;font-size:14px;width:560px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">FULL DETAILS / T&C's / HOW TO REDEEM</h1>
        
               <p style="font-size:10px;"><br/>
  
<?php
$productClass = hikashop_get('class.product');
foreach($data->cart->products as $item){
   $product = $productClass->get($item->product_id);
  echo $item->order_product_name.'<strong></strong>';
   echo $product->product_description.'<br/><hr><br/>';

} ?>
                 </p>
               
               </td>
           </tr>
         </table>
                          
                          <!-- { end terms and conditions info} -->

This is the pdf code i use... this shows but not when the product has a variant...
<table width="100%" border="0">
  <tr>
             <td>         <h1 style="background-color:#333;font-size:14px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">Full Details / T&C's / How to Redeem...</h1>
        
               <p style="font-size:10px;"><br/>
  
<?php
$productClass = hikashop_get('class.product');
foreach($order->products as $item){
   $product = $productClass->get($item->product_id);
  echo $item->order_product_name.'<strong></strong>';
   echo $product->product_description.'<br/><hr><br/>';

} ?>
                 </p>
               
               </td>
           </tr>
         </table>

Kind regards

Alex

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
10 years 3 months ago #166417

Hi,

That's normal since you entered the description only in the main product, not in each variant.
If you want that code to work with variants too, you'll have to make it more complex. Something like that:

<?php
$productClass = hikashop_get('class.product');
foreach($order->products as $item){
   $product = $productClass->get($item->product_id);
  echo $item->order_product_name.'<strong></strong>';
   if($product->product_type=='variant'){
     $product = $productClass->get($product->product_parent_id);
  }
   echo $product->product_description.'<br/><hr><br/>';

} ?>

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166440

Aha i see, I didnt know if the value of the main product was the default if no other was entered in the variant. I have added this to the email and it seems to work really well. The PDF on the other hand still wont generate on products with variants, even if i take out the code I added about the product description. This is the code i am using in the invoice.php file please can you see if it works for you when someone buys a product with a variant?

<?php
/**
 * @copyright	Copyright (C) 2009-2012 ACYBA SARL - All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 */
defined('_JEXEC') or die('Restricted access');
?>

<style type="text/css">
<!--
.invoicetitle{ text-align:center;font-size:30px; padding-top:40px;padding-bottom:40px}
legend { padding:5px 10px; background-color:#5471B5;color:white;font-weight:bold;border-color:#ccc}
fieldset { padding:10px; border-color:#ccc;}

div.date{text-align:right;color:#333;}

.storeaddress{
	color:#333;
}
.addresses{padding-top:50px;}
.addresses td{padding-left:50px;}
.addresses fieldset {float:left;}

table.products{margin:auto;margin-top:60px;width:580px;border-collapse:collapse}
.price{text-align:center;}

.products td, .products th{border:1px solid #ccc;padding:7px 4px;}
.products th{background-color:#5471B5;color:white;}
td.newarea{text-align:right;padding-right:20px;}
tr.total{font-weight:bold;}

.products tr.limitation td{background-color:#ccc;padding:1px 0px;}

.hikashop_order_custom_fields_fieldset{margin-top : 20px;}

.footer{font-size:10px;color:#aaa;text-align:center;}
-->
</style>
<page style="font-size: 12px" backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm">
	<page_footer>
	<div class="footer">
		<?php echo str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'),$this->params->get('footer')); ?>
	</div>
	</page_footer>
	<div class="storeaddress">
		<!--<?php
			$store = str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'),$config->get('store_address',''));
			if(JText::_($store)!=$store){
				$store = JText::_($store);
			}
			echo $store;
		?>-->
	</div>
	<?php if(empty($order->order_invoice_number)){
		$order->order_invoice_number = $order->order_number;
	}
	if(empty($order->order_invoice_created)){
		$order->order_invoice_created = $order->order_created;
	} ?>
	<div style="margin-left:auto; margin-right:auto; margin-top:-30px;"><p style="text-align:center;"><img class="w600" src="images/voucher-pdf-header.png" border="0" alt="" /></p></div>
	<div class="invoicetitle" style="font-size:24px;">Voucher Code: <?php echo $order->order_invoice_number; ?></div>
	<div class="date" style="margin-bottom:-20px; margin-top:-20px;"><p style="text-align:center;"><?php echo JText::_('DATE').' Purchased: '.hikashop_getDate($order->order_invoice_created,'%d %B %Y ');?></p>
	
	<p style="text-align:center;">Please quote your voucher code when contacting the venue to redeem. If you have purchased more than one deal the same code will be valid multiple times.</p>
	
	</div>

	<!--<table class="addresses">
		<tr>
			<?php
			$addresses = array('billing_address','shipping_address');
			foreach($addresses as $oneAddress){
			if(empty($order->$oneAddress)) continue;
			if ($oneAddress=='shipping_address' && empty($pluginsShipping)) continue; ?>
			<td valign="top">
				<fieldset>
				<legend><?php echo JText::_('HIKASHOP_'.strtoupper($oneAddress)); ?></legend>
					<?php
					if(!empty($order->$oneAddress->address_company)) echo $order->$oneAddress->address_company.'<br/>';
					echo $order->$oneAddress->address_title.' '.$order->$oneAddress->address_firstname.' '.$order->$oneAddress->address_lastname.'<br/>';
					echo $order->$oneAddress->address_street.'<br/>';
					echo $order->$oneAddress->address_post_code.' '.$order->$oneAddress->address_city.' '.$order->$oneAddress->address_state.'<br/>';
					echo $order->$oneAddress->address_country.'<br/>';
					if(!empty($order->$oneAddress->address_telephone)) echo JText::sprintf('TELEPHONE_IN_ADDRESS',$order->$oneAddress->address_telephone).'<br/>';
					if(!empty($order->$oneAddress->address_vat)) echo JText::_('VAT_NUMBER').' : '.$order->$oneAddress->address_vat.'<br/>';
					?>
				</fieldset>
			</td>
			<?php } ?>
		</tr>
	</table>-->

	<table class="products">
		<tr class="products_title">
			<th style="width:300px; background-color:#FF8811;">
				<?php echo JText::_('PRODUCT'); ?>
			</th>
			<th style="width:100px; background-color:#333;" class="price">
				<?php echo JText::_('UNIT_PRICE'); ?>
			</th>
			<th style="width:80px; background-color:#333;" class="price">
				<?php echo JText::_('PRODUCT_QUANTITY'); ?>
			</th>
			<th style="width:100px; background-color:#333;" class="price">
				<?php echo JText::_('PRICE'); ?>
			</th>
		</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($order->products as $product){
			if($group && $product->order_product_option_parent_id) continue;
			?>
			<tr>
				<td>

					<?php echo implode('<br/>',$this->str_split_unicode($product->order_product_name,50));
					if($group){
						$display_item_price=false;
						foreach($order->products as $j => $optionElement){
							if($optionElement->order_product_option_parent_id != $product->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($product->order_product_price+$product->order_product_tax,$order->order_currency_id);
							}else{
								echo ' '.$currencyHelper->format($product->order_product_price,$order->order_currency_id);
							}
						}
					}
					if(!empty($fields['item'])){
						foreach($fields['item'] as $field){
							$namekey = $field->field_namekey;
							if(empty($product->$namekey)) continue;
							echo '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$product->$namekey).'</p>';
						}
					}
					if($group){
						foreach($order->products as $j => $optionElement){
							if($optionElement->order_product_option_parent_id != $product->order_product_id) continue;

							$product->order_product_price +=$optionElement->order_product_price;
							$product->order_product_tax +=$optionElement->order_product_tax;
							$product->order_product_total_price+=$optionElement->order_product_total_price;
							$product->order_product_total_price_no_vat+=$optionElement->order_product_total_price_no_vat;
							?><br/><?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,$order->order_currency_id).' )';
								}else{
									echo ' ( + '.$currencyHelper->format($optionElement->order_product_price,$order->order_currency_id).' )';
								}
							}
						}
					} ?>
				</td>
				<td  class="price">
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($product->order_product_price+$product->order_product_tax,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($product->order_product_price,$order->order_currency_id);
				} ?>
				</td>
				<td  class="price">
					<?php echo $product->order_product_quantity;?>
				</td>
				<td  class="price">
					<?php
					if($config->get('price_with_tax')){
						echo $currencyHelper->format($product->order_product_total_price,$order->order_currency_id);
					}else{
						echo $currencyHelper->format($product->order_product_total_price_no_vat,$order->order_currency_id);
					} ?>
				</td>
			</tr>
			<?php
		}
	?>
		<tr class="limitation"><td colspan="4"></td></tr>
		<tr>
			<td colspan="3" class="newarea">
					<?php echo JText::_( 'SUBTOTAL' ); ?>
			</td>
			<td  class="price">
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($order->order_subtotal,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($order->order_subtotal_no_vat,$order->order_currency_id);
				} ?>
			</td>
		</tr>
		<?php $taxes = $order->order_subtotal - $order->order_subtotal_no_vat - $order->order_discount_tax + $order->order_shipping_tax;;

		if(!empty($order->order_discount_code)){ ?>
		<tr>
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_COUPON' ); ?>
			</td>
			<td  class="price">
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($order->order_discount_price*-1,$order->order_currency_id);
				}else{
					echo $currencyHelper->format(($order->order_discount_price-@$order->order_discount_tax)*-1,$order->order_currency_id);
				}
				?>
			</td>
		</tr>
		<?php }

		if(!empty($order->order_shipping_method)){ ?>
		<tr>
			<td colspan="3" class="newarea">
					<?php echo JText::_( 'SHIPPING' ); ?>
			</td>
			<td  class="price" >
				<?php
				if($config->get('price_with_tax')){
					echo $currencyHelper->format($order->order_shipping_price,$order->order_currency_id);
				}else{
					echo $currencyHelper->format($order->order_shipping_price-@$order->order_shipping_tax,$order->order_currency_id);
				} ?>
			</td>
		</tr>
		<?php }
		if(!empty($order->additional)) {
			$exclude_additionnal = explode(',', $config->get('order_additional_hide', ''));
			foreach($order->additional as $additional) {
				if(in_array($additional->name, $exclude_additionnal)) continue;
				echo '<tr><td colspan="3" class="newarea">'. JText::_($additional->order_product_name).'</td><td  class="price">';
				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, $order->order_currency_id);
					}else{
						echo $currencyHelper->format($additional->order_product_price, $order->order_currency_id);
					}
				} else {
					echo $additional->order_product_options;
				}
				echo '</td></tr>';
			}
		}
		if($taxes != 0){
			if($config->get('detailed_tax_display') && !empty($order->order_tax_info)){
				foreach($order->order_tax_info as $tax){ ?>
				<tr>
					<td colspan="3" class="newarea">
						<?php echo $tax->tax_namekey; ?>
					</td>
					<td  class="price">
						<?php echo $currencyHelper->format($tax->tax_amount,$order->order_currency_id); ?>
					</td>
				</tr>
			<?php
				}
			}else{ ?>
				<tr>
					<td colspan="3" class="newarea">
						<?php echo JText::_( 'VAT' ); ?>
					</td>
					<td  class="price">
						<?php echo $currencyHelper->format($taxes,$order->order_currency_id); ?>
					</td>
				</tr>
		<?php }
		} ?>
		<?php
		if(!empty($order->order_payment_method) && $order->order_payment_price != 0){ ?>
		<tr>
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_PAYMENT' ); ?>
			</td>
			<td class="price" >
				<?php echo $currencyHelper->format($order->order_payment_price,$order->order_currency_id); ?>
			</td>
		</tr>
		<?php } ?>
		<tr class="total">
			<td colspan="3" class="newarea">
				<?php echo JText::_( 'HIKASHOP_TOTAL' ); ?>
			</td>
			<td  class="price" >
				<?php echo $currencyHelper->format($order->order_full_price,$order->order_currency_id); ?>
			</td>
		</tr>
	</table>
	
					  
	<table width="100%" border="0">
  <tr>
             <td>         <h1 style="background-color:#333;font-size:14px;padding:5px; text-align:center; color:#fff; font-family:Arial, Helvetica, sans-serif;">Full Details / T&C's / How to Redeem...</h1>
        
               <p style="font-size:10px;"><br/>
  


<?php
$productClass = hikashop_get('class.product');
foreach($order->products as $item){
   $product = $productClass->get($item->product_id);
  echo $item->order_product_name.'<strong></strong>';
   if($product->product_type=='variant'){
     $product = $productClass->get($product->product_parent_id);
  }
   echo $product->product_description.'<br/><hr><br/>';

} ?>

                 </p>
               
               </td>
           </tr>
         </table>
         
	<p>
	  <?php
		if (!empty($pluginsShipping))
			echo JText::_('HIKASHOP_SHIPPING_METHOD').' : '.$pluginsShipping->getName($order->order_shipping_method, $order->order_shipping_id).'<br/>' ;
		if(!empty($pluginsPayment))
			echo JText::_('HIKASHOP_PAYMENT_METHOD').' : '.$pluginsPayment->getName($order->order_payment_method, $order->order_payment_id).'<br/>';
	?>
    </p>
	<br/>
	<?php if(hikashop_level(2) && !empty($fields['order'])){?>
	<fieldset class="hikashop_order_custom_fields_fieldset">
		<legend><?php echo JText::_('ADDITIONAL_INFORMATION'); ?></legend>
		<table class="hikashop_order_custom_fields_table adminlist" cellpadding="1" width="100%">
			<?php foreach($fields['order'] as $fieldName => $oneExtraField) {
				if(!@$oneExtraField->field_frontcomp || empty($order->$fieldName)) continue;
			?>
				<tr class="hikashop_order_custom_field_<?php echo $fieldName;?>_line">
					<td class="key">
						<?php echo $fieldsClass->getFieldName($oneExtraField);?>
					</td>
					<td>
						<?php echo $fieldsClass->show($oneExtraField,$order->$fieldName); ?>
					</td>
				</tr>
			<?php }	?>
		</table>
	</fieldset>
	<br/>

	<?php } ?>
			<div style="margin-left:auto; margin-right:auto; margin-top:0px;"><p style="text-align:center;"><img class="w600" src="images/voucher-footer-pdf.png" border="0" alt="" /></p></div>

</page>

Kind regards

Alex

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
10 years 3 months ago #166450

Hi,

Maybe it's because of the <hr> tag as it should be <hr/> ?
The best is to go back to the default code of the plugin (that you have in the package of the plugin and try again with it. It should work. If not, then there is an issue with the HTML of the products with variants on your website.
In that case, try to remove the line:
echo implode('<br/>',$this->str_split_unicode($product->order_product_name,50));
That's what displays the product name. If it works without it, then the problem is with the product names of variants.
In that case, try like that instead:
echo implode('<br/>',$this->str_split_unicode(strip_tags($product->order_product_name),50));

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166555

Hi Nicolas,

The default code didn't work however when i replace the line you mentioned it now works so thanks for your help. I guess that this would apply to anyone who uses this plugin.

Kind regards

Alex

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
10 years 3 months ago #166571

Hi,

Yes, we'll publish a new version of the plugin with the change.

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
10 years 3 months ago #166919

Hi Nicolas,

I am pretty certain i have not changed the PDF php in anyway but now i cannot send confirmation email and get the message:

TCPDF ERROR: Could not include font definition file: 'arial'

The customer also gets this when trying to download their PDF do you have any ideas?

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166920

I know what is happening here, it looks like where we used some styling in the product description it was trying to pull this into the PDF so that seemed to be throwing up the error so i guess we need to use no custom css styling on the product descriptions.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
10 years 3 months ago #166951

Yes, if you include extra fonts with inline CSS, the font need to be registered with the TCPD library. So it's better not to do that and only define onts via CSS code in your template/hikashop frontend CSS file, not directly inline in the descriptions.

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

  • Posts: 377
  • Thank you received: 7
10 years 3 months ago #166993

I see what i have done is updated jce editor to strip out span styles by default to prevent customers in hikamarket pasting content from word.

Kind regards

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

Time to create page: 0.048 seconds
Powered by Kunena Forum