Tracking # custom field not working after update

  • Posts: 128
  • Thank you received: 3
8 years 7 months ago #235042

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.5.0
-- PHP version -- : 5.3.24

I have created a custom field for the order table for tracking numbers.



Once I had an item ready to ship I would take the tracking number and edit the appropriate order in the back end by adding the tracking number into the field. I then had my order status notification email where it would add this tracking number when the status was shipped. Here is my html version of the email
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.5.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><style type="text/css">
body.hikashop_mail { background-color:#ffffff; color:#000; }
.ReadMsgBody{width:100%;}
.ExternalClass{width:100%;}
div, p, a, li, td {-webkit-text-size-adjust:none;}
@media (min-width:600px){
	#hikashop_mail {width:600px !important;margin:auto !important;}
	.pict img {max-width:500px !important;height:auto !important;}
}
@media (max-width:330px){
	#hikashop_mail{width:300px !important; margin:auto !important;}
	table[class=w600], td[class=w600], table[class=w598], td[class=w598], table[class=w500], td[class=w500], img[class="w600"]{width:100% !important;}
	td[class="w49"] { width: 10px !important;}
	.pict img {max-width:278px; height:auto !important;}
}
@media (min-width:331px) and (max-width:480px){
	#hikashop_mail{width:450px !important; margin:auto !important;}
	table[class=w600], td[class=w600], table[class=w598], td[class=w598], table[class=w500], td[class=w500], img[class="w600"]{width:100% !important;}
	td[class="w49"] { width: 20px !important;}
	.pict img {max-width:408px;  height:auto !important;}
}
h1{color:#000;font-size:16px;font-weight:normal;padding-bottom:10px;}
h2{color:#000;font-size:14px;font-weight:normal;margin-top:20px;margin-bottom:5px;padding-bottom:4px;}
a{cursor:pointer;color:#468852;text-decoration:none;border:none;}
a:hover,a:focus{cursor:pointer;color:#468852;text-decoration:underline;border:none;}
a:visited{cursor:pointer;color:#2d9cbb;text-decoration:none;border:none;}
</style>

<div id="hikashop_mail" style="font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;width:100%;background-color:#ffffff;padding-bottom:20px;color:#000;">
	<!--{IF:USER_ACCOUNT}-->
	<div class="hikashop_online" style="font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:11px;line-height:18px;color:#000;text-decoration:none;margin:10px;text-align:center;">
		<a style="cursor:pointer;color:#468852;text-decoration:none;border:none;" href="{VAR:URL}">
			<span class="hikashop_online" style="color:#000;text-decoration:none;font-size:11px;margin-top:10px;margin-bottom:10px;text-align:center;">
				{TXT:MAIL_HEADER}
			</span>
		</a>
	</div>
	<!--{ENDIF:USER_ACCOUNT}-->
	<table class="w600" style="font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;margin:auto;background-color:#ffffff;" border="0" cellspacing="0" cellpadding="0" width="600" align="center">
		<tr>
			<td class="w600" style="" width="600" align="center">
				<table class="w600" border="0" cellspacing="0" cellpadding="0" width="600" style="margin:0px;font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;">
					<tr>
						<td class="w20" width="20"></td>
						<td class="w560 pict" style="text-align:left; color:#000" width="560">
							<div id="title" style="font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;">

<img src="{VAR:LIVE_SITE}/templates/tntmunitions/images/TNTMunitionsLogo.png" border="0" alt="" style="float:left;margin-top:-20px;margin-right:10px;width:50px;"/>
<h1 style="color:#000 !important;font-size:16px;font-weight:normal;padding-bottom:10px">
	{TXT:ORDER_TITLE}
</h1>
							</div>
						</td>
						<td class="w20" width="20"></td>
					</tr>
					<tr>
						<td class="w20" width="20"></td>
						<td style="border:1px solid #adadad;background-color:#ffffff;">
							<div class="w550" width="550" id="content" style="font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;margin-left:5px;margin-right:5px;">
<p>
	<h3 style="color:#000 !important; font-size:14px; font-weight:normal;margin-bottom:0px;padding:0px;">{TXT:HI_CUSTOMER}</h3>
	{TXT:ORDER_BEGIN_MESSAGE}
</p>

<table class="w550" border="0" cellspacing="0" cellpadding="0" width="550" style="margin-top:10px;font-family:Courier New, Monaco, Menlo, Consolas, monospace;font-size:12px;line-height:18px;">
	<tr>
		<!--{IF:BILLING_ADDRESS}--><td style="color:#000 !important;font-size:12px;font-weight:normal;">{TXT:BILLING_ADDRESS}</td><!--{ENDIF:BILLING_ADDRESS}-->
		<!--{IF:SHIPPING}--><!--{IF:SHIPPING_ADDRESS}--><td style="color:#000 !important;font-size:12px;font-weight:normal;">{TXT:SHIPPING_ADDRESS}</td><!--{ENDIF:SHIPPING_ADDRESS}--><!--{ENDIF:SHIPPING}-->
	</tr>
	<tr>
		<!--{IF:BILLING_ADDRESS}--><td>{VAR:BILLING_ADDRESS}</td><!--{ENDIF:BILLING_ADDRESS}-->
		<!--{IF:SHIPPING}--><!--{IF:SHIPPING_ADDRESS}--><td>{VAR:SHIPPING_ADDRESS}</td><!--{ENDIF:SHIPPING_ADDRESS}--><!--{ENDIF:SHIPPING}-->
	</tr>
</table>
<p>
    <span style="color:#000 !important;font-size:12px;font-weight:normal; padding-bottom:10px">{TXT:ORDER_CHANGED}</span>
</p>
<!--{IF:PAYMENT}-->
<p>
	<span style="color:#000 !important;font-size:12px;font-weight:normal;">{TXT:PAYMENT_METHOD} :</span> {VAR:PAYMENT}
</p>
<!--{ENDIF:PAYMENT}-->
<!--{IF:SHIPPING}-->
<p>
	<span style="color:#000 !important;font-size:12px;font-weight:normal;">{TXT:HIKASHOP_SHIPPING_METHOD} :</span> {VAR:SHIPPING}
</p>
<p>
	<span style="color:#000 !important;font-size:12px;font-weight:normal;">Your tracking numbers are :</span> {VAR:TRACKING}
</p>
<!--{ENDIF:SHIPPING}-->
<!--{IF:ORDER_SUMMARY}-->
<h1 style="color:#000 !important;font-size:16px;font-weight:normal;border-bottom:1px solid #ddd;padding-top:10px;padding-bottom:10px;">
	{TXT:ADDITIONAL_INFORMATION}
</h1>
<p style="border-bottom:1px solid #ddd;padding-bottom:10px;">
	{VAR:ORDER_SUMMARY}
</p>
<!--{ENDIF:ORDER_SUMMARY}-->
<p>
	{TXT:ORDER_END_MESSAGE}
</p>
							</div>
						</td>
						<td class="w20" width="20"></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</div>

Here is my text version
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.5.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name)."\n"."\n";?>
<?php
$url = $data->order_number;
$config =& hikashop_config();
if($config->get('simplified_registration',0)!=2){
	$url .= "\n".'( '.$data->order_url.' )'."\n";
}
if(!empty($data->usermsg->usermsg)){
	echo $data->usermsg->usermsg;
}else{
	echo JText::sprintf('ORDER_STATUS_CHANGED_TO',$url,$data->mail_status).'\r\n';
}
if($data->mail_status == "shipped" && !empty($data->trackingnumber)) {
	echo 'Your tracking numbers are '.str_replace(",",", ",$data->trackingnumber).'.\r\n';
}
echo "\n"."\n";
?>
<?php echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER',HIKASHOP_LIVE)."\n"."\n"."\n";?>
<?php echo str_replace('<br/>',"\n",JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name.' Team'));?>

and here is the preload
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.5.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

$app = JFactory::getApplication();
$config = hikashop_config();
$orderClass = hikashop_get('class.order');
$imageHelper = hikashop_get('helper.image');
$productClass = hikashop_get('class.product');
$fieldsClass = hikashop_get('class.field');
if(hikashop_level(2)) {
	$null = null;
	$itemFields = $fieldsClass->getFields('frontcomp',$null,'item');
}

global $Itemid;
$url_itemid = '';
if(!empty($Itemid)) {
	$url_itemid = '&Itemid=' . $Itemid;
}
if(isset($data->url_itemid)) {
	$url_itemid = (!empty($data->url_itemid) ? '&Itemid=':'') . $data->url_itemid;
}

$order_url = $data->order_url;
$mail_status = $data->mail_status;
$customer = $data->customer;

if(!isset($data->order))
	$data->order = new stdClass();
$fs = array('order_number','order_discount_tax','order_shipping_tax','order_full_price','order_shipping_price','order_payment_price','order_discount_price','order_currency_id','order_status');
foreach($fs as $f) {
	if(isset($data->$f) && !isset($data->order->$f))
		$data->order->$f = $data->$f;
}

$url = $data->order->order_number;
$data->order->order_url = $order_url;

if(!empty($customer->user_cms_id) && (int)$customer->user_cms_id != 0) {
	$url = '<a href="'.$order_url.'">'. $url.'</a>';
}

$data->cart = $orderClass->loadFullOrder($data->order_id,true,false);
$data->cart->coupon = new stdClass();
$price = new stdClass();
$tax = $data->cart->order_subtotal - $data->cart->order_subtotal_no_vat - $data->cart->order_discount_tax + $data->cart->order_shipping_tax;
$price->price_value = $data->cart->order_full_price - $tax;
$price->price_value_with_tax = $data->cart->order_full_price;
$data->cart->full_total = new stdClass;
$data->cart->full_total->prices = array($price);
$data->cart->coupon->discount_value =& $data->cart->order_discount_price;

if($app->isAdmin()) {
	$view = 'order';
} else {
	$view = 'address';
}
$colspan = 4;

$customer_name = @$customer->name;
if(empty($customer_name))
	$customer_name = @$data->cart->billing_address->address_firstname.' '.@$data->cart->billing_address->address_lastname;

$vars = array(
	'LIVE_SITE' => HIKASHOP_LIVE,
	'URL' => $order_url,
	'ORDER_PRODUCT_CODE' => (bool)$config->get('show_code', false),
	'order' => $data->cart,
	'user' => $customer,
	'billing_address' => @$data->cart->billing_address,
	'shipping_address' => @$data->cart->shipping_address,
);
$texts = array(
	'BILLING_ADDRESS' => JText::_('HIKASHOP_BILLING_ADDRESS'),
	'SHIPPING_ADDRESS' => JText::_('HIKASHOP_SHIPPING_ADDRESS'),
	'SUMMARY_OF_YOUR_ORDER' => JText::_('SUMMARY_OF_YOUR_ORDER'),
	'MAIL_HEADER' => JText::_('HIKASHOP_MAIL_HEADER'),
	'USER_ACCOUNT' => (bool)@$customer->user_cms_id,
	'PRODUCT_NAME' => JText::_('CART_PRODUCT_NAME'),
	'PRODUCT_CODE' => JText::_('CART_PRODUCT_CODE'),
	'PRODUCT_PRICE' => JText::_('CART_PRODUCT_UNIT_PRICE'),
	'PRODUCT_QUANTITY' => JText::_('CART_PRODUCT_QUANTITY'),
	'PRODUCT_TOTAL' => JText::_('HIKASHOP_TOTAL'),
	'ADDITIONAL_INFORMATION' => JText::_('ADDITIONAL_INFORMATION'),

	'ORDER_TITLE' => JText::_('YOUR_ORDER'),
	'HI_CUSTOMER' => JText::sprintf('HI_CUSTOMER', $customer_name),
	'ORDER_CHANGED' => JText::sprintf('ORDER_STATUS_CHANGED_TO', $url, $data->mail_status),
	'ORDER_BEGIN_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_BEGIN', HIKASHOP_LIVE),
	'ORDER_END_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER', HIKASHOP_LIVE) . '<br/>' . JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name.' Team'),
);
if(!empty($data->usermsg->usermsg)){
	$texts['ORDER_CHANGED'] = $data->usermsg->usermsg;
}
$templates = array();

$products_ids = array();
foreach($data->cart->products as $item) { $products_ids[] = $item->product_id; }
$productClass->getProducts($products_ids);

$cartProducts = array();
$cartFooters = array();
{
	$group = $config->get('group_options',0);
	$subtotal = 0;
	foreach($data->cart->products as $item) {
		if($group && $item->order_product_option_parent_id)
			continue;

		$product = @$productClass->all_products[$item->product_id];

		$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTITY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
			'item' => $item,
			'product' => $product,
		);

		if(!empty($item->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
			$img = $imageHelper->getThumbnail($item->images[0]->file_path, array(50, 50), array('forcesize' => true, 'scale' => 'outside'));
			if($img->success) {
				if(substr($img->url, 0, 3) == '../')
					$image = str_replace('../', HIKASHOP_LIVE, $img->url);
				else
					$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
				$cartProduct['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
			}
		}

		$t = '<p>' . $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')){
					$t .= ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->cart->order_currency_id);
				}else{
					$t .= ' '.$currencyHelper->format($item->order_product_price,$data->cart->order_currency_id);
				}
			}
		}
		$t .= '</p>';

		if(!empty($itemFields)){
			foreach($itemFields as $field){
				$namekey = $field->field_namekey;
				if(!isset($item->$namekey) || (empty($item->$namekey) && !strlen($item->$namekey))) continue;
				$t .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey,'user_email').'</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;

				$t .= '<p class="hikashop_order_option_name">' . $optionElement->order_product_name;
				if($optionElement->order_product_price>0){
					if($config->get('price_with_tax')){
						$t .= ' ( + '.$currencyHelper->format($optionElement->order_product_price+$optionElement->order_product_tax,$data->cart->order_currency_id).' )';
					}else{
						$t .= ' ( + '.$currencyHelper->format($optionElement->order_product_price,$data->cart->order_currency_id).' )';
					}
				}
				$t .= '</p>';
			}
		}
		$cartProduct['PRODUCT_NAME'] = $t;

		$t = '';
		$statusDownload = explode(',',$config->get('order_status_for_download','confirmed,shipped'));
		if(!empty($item->files) && in_array($data->order->order_status,$statusDownload)){
			$t .= '<p>';
			foreach($item->files as $file){
				$fileName = empty($file->file_name) ? $file->file_path : $file->file_name;
				$file_pos = empty($file->file_pos) ? '' : ('&file_pos=' . $file->file_pos);
				if(empty($customer->user_cms_id))
					$file_pos .= '&email=' . $customer->user_email;
				$oid = $data->order_id;
				if(!empty($data->cart->order_parent_id))
					$oid = $data->cart->order_parent_id;
				$t .= '<a href="'.hikashop_frontendLink('index.php?option=com_hikashop&ctrl=order&task=download&file_id='.$file->file_id.'&order_id='.$oid.$file_pos.$url_itemid).'">'.$fileName.'</a><br/>';
			}
			$t .= '</p>';
		}
		$cartProduct['PRODUCT_DOWNLOAD'] = $t;

		if($config->get('price_with_tax')){
			$unit_price = $currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->cart->order_currency_id);
			$total_price = $currencyHelper->format($item->order_product_total_price,$data->cart->order_currency_id);
			$subtotal += $item->order_product_total_price;
		}else{
			$unit_price = $currencyHelper->format($item->order_product_price,$data->cart->order_currency_id);
			$total_price = $currencyHelper->format($item->order_product_total_price_no_vat,$data->cart->order_currency_id);
			$subtotal += $item->order_product_total_price_no_vat;
		}
		$cartProduct['PRODUCT_PRICE'] = $unit_price;
		$cartProduct['PRODUCT_TOTAL'] = $total_price;

		$cartProducts[] = $cartProduct;
	}
	$templates['PRODUCT_LINE'] = $cartProducts;

	if(bccomp($data->cart->order_discount_price,0,5) || bccomp($data->cart->order_shipping_price,0,5) || bccomp($data->cart->order_payment_price,0,5) || ($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) || !empty($data->cart->additional)){
		$cartFooters[] = array(
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
		);
	}
	if(bccomp($data->cart->order_discount_price,0,5)) {
		if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_discount_price*-1,$data->cart->order_currency_id);
		}else{
			$t = $currencyHelper->format(($data->cart->order_discount_price-@$data->cart->order_discount_tax)*-1,$data->cart->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_COUPON'),
			'VALUE' => $t
		);
	}
	if(bccomp($data->cart->order_shipping_price,0,5)){
		if($config->get('price_with_tax')) {
			$t = $currencyHelper->format($data->cart->order_shipping_price,$data->cart->order_currency_id);
		}else{
			$t = $currencyHelper->format($data->cart->order_shipping_price-@$data->cart->order_shipping_tax,$data->cart->order_currency_id);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_SHIPPING'),
			'VALUE' => $t
		);
	}
	if(bccomp($data->cart->order_payment_price,0,5)){
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_PAYMENT'),
			'VALUE' => $currencyHelper->format($data->cart->order_payment_price,$data->cart->order_currency_id)
		);
	}
	if(!empty($data->cart->additional)) {
		$exclude_additionnal = explode(',', $config->get('order_additional_hide', ''));
		foreach($data->cart->additional as $additional) {
			if(in_array($additional->order_product_name, $exclude_additionnal))
				continue;

			if(!empty($additional->order_product_price) || empty($additional->order_product_options)) {
				if($config->get('price_with_tax')){
					$t = $currencyHelper->format($additional->order_product_price + @$additional->order_product_tax, $data->cart->order_currency_id);
				}else{
					$t = $currencyHelper->format($additional->order_product_price, $data->cart->order_currency_id);
				}
			} else {
				$t = $additional->order_product_options;
			}
			$cartFooters[] = array(
				'NAME' => JText::_($additional->order_product_name),
				'VALUE' => $t
			);
		}
	}

	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) {
				$cartFooters[] = array(
					'NAME' => $tax->tax_namekey,
					'VALUE' => $currencyHelper->format($tax->tax_amount,$data->cart->order_currency_id)
				);
			}
		} else {
			$cartFooters[] = array(
				'NAME' => JText::_('ORDER_TOTAL_WITHOUT_VAT'),
				'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value,$data->cart->order_currency_id)
			);
		}
		$cartFooters[] = array(
			'NAME' => JText::_('ORDER_TOTAL_WITH_VAT'),
			'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
		);
	} else {
		$cartFooters[] = array(
			'NAME' => JText::_('HIKASHOP_TOTAL'),
			'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
		);
	}

	$templates['ORDER_FOOTER'] = $cartFooters;
}

if(!empty($data->cart->order_payment_method)) {
	if(!is_numeric($data->cart->order_payment_id)){
		$vars['PAYMENT'] = $data->cart->order_payment_method.' '.$data->cart->order_payment_id;
	}else{
		$paymentClass = hikashop_get('class.payment');
		$payment = $paymentClass->get($data->cart->order_payment_id);
		$vars['PAYMENT'] = $payment->payment_name;
		unset($paymentClass);
	}
}

if(!empty($data->cart->order_shipping_id)) {
	$shippingClass = hikashop_get('class.shipping');
	if(!empty($data->cart->order_shipping_method)) {
		if(!is_numeric($data->cart->order_shipping_id)){
			$shipping_name = $shippingClass->getShippingName($data->cart->order_shipping_method, $data->cart->order_shipping_id);
			$vars['SHIPPING'] = $shipping_name;
			$vars['SHIPPING_TXT'] = $vars['SHIPPING'];
		}else{
			$shipping = $shippingClass->get($data->cart->order_shipping_id);
			$vars['SHIPPING'] = $shipping->shipping_name;
			$vars['SHIPPING_TXT'] = $vars['SHIPPING'];
		}
	} else {
		$shippings_data = array();
		$shipping_ids = explode(';', $data->cart->order_shipping_id);
		$shippingClass = hikashop_get('class.shipping');
		foreach($shipping_ids as $key) {
			$shipping_data = '';
			list($k, $w) = explode('@', $key);
			$shipping_id = $k;
			if(isset($data->cart->shippings[$shipping_id])) {
				$shipping = $data->cart->shippings[$shipping_id];
				$shipping_data = $shipping->shipping_name;
			} else {
				foreach($data->cart->products as $order_product) {
					if($order_product->order_product_shipping_id == $key) {
						if(!is_numeric($order_product->order_product_shipping_id)){
							$shipping_name = $shippingClass->getShippingName($order_product->order_product_shipping_method, $shipping_id);
							$shipping_data = $shipping_name;
						}else{
							$shipping_method_data = $shippingClass->get($shipping_id);
							$shipping_data = $shipping_method_data->shipping_name;
						}
						break;
					}
				}
				if(empty($shipping_data))
					$shipping_data = '[ ' . $key . ' ]';
			}
			if(isset($data->cart->order_shipping_params->prices[$key])) {
				$price_params = $data->cart->order_shipping_params->prices[$key];
				if($config->get('price_with_tax')){
					$shipping_data .= ' (' . $currencyHelper->format($price_params->price_with_tax, $data->cart->order_currency_id) . ')';
				}else{
					$shipping_data .= ' (' . $currencyHelper->format($price_params->price_with_tax - @$price_params->tax, $data->cart->order_currency_id) . ')';
				}
			}
			$shippings_data[] = $shipping_data;
		}
		if(!empty($shippings_data)) {
			$vars['SHIPPING'] = '<ul><li>'.implode('</li><li>', $shippings_data).'</li></ul>';
			$vars['SHIPPING_TXT'] = ' - ' . implode("\r\n - ", $shippings_data);
			$tracking_link = array();
			$tracking = array();
			foreach($shippings_data as $ship_method){
				if(strpos($ship_method,'FedEx') !== false){
					$tracking_link['FedEx']='<a href="http://www.fedex.com/Tracking?action=track&tracknumbers=';
				}
				if(strpos($ship_method,'UPS') !== false){
					$tracking_link['UPS']='<a href="http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=';
				}
				if(strpos($ship_method,'USPS') !== false){
					$tracking_link['USPS']='<a href="https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=';
				}
				
			}
			if(!empty($data->trackingnumber)){
				$tracking_number = explode(',',$data->trackingnumber);
				foreach($tracking_number as $value){
                  if(strlen($value) <= 14){
                      $tracking['FedEx']=$value;
                  }
				  if(substr($value,0,2) === '1Z' && strlen($value) <= 18){
                      $tracking['UPS']=$value;
                  }
				  if(substr($value,0,1) === '9' && strlen($value) <= 22){
                      $tracking['USPS']=$value;
                  }
				}
				$tracking=array_combine(array_intersect_key($tracking_link,$tracking),array_intersect_key($tracking,$tracking_link));
				$vars['TRACKING'] = '<ul>';
				$vars['TRACKING_TXT'] = '';
				foreach($tracking as $key=>$value){
					$vars['TRACKING'] .= '<li>'.$key.$value.'">'.$value.'</a>';
					$vars['TRACKING_TXT'] .= '- '.$value.'\r\n';
				}
				$vars['TRACKING'] .= '</ul>';
			}
		}
	}
	unset($shippingClass);
} else {
	$vars['SHIPPING'] = '';
}

ob_start();

	$sep = '';
	if(hikashop_level(2)) {
		$fields = $fieldsClass->getFields('frontcomp',$data,'order','');
		foreach($fields as $fieldName => $oneExtraField) {
			if(isset($data->$fieldName) && !isset($data->cart->$fieldName))
				$data->cart->$fieldName = $data->$fieldName;
			if(empty($data->cart->$fieldName))
				continue;
			echo $sep . $fieldsClass->trans($oneExtraField->field_realname).' : '.$fieldsClass->show($oneExtraField, $data->cart->$fieldName,'user_email');
			$sep = '<br />';
		}
	}

	JPluginHelper::importPlugin('hikashop');
	$dispatcher = JDispatcher::getInstance();
	$dispatcher->trigger('onAfterOrderProductsListingDisplay', array(&$data->cart, 'email_notification_html'));

$content = ob_get_clean();
$vars['ORDER_SUMMARY'] = trim($content);

$vars['BILLING_ADDRESS'] = '';
$vars['SHIPPING_ADDRESS'] = '';

$addressClass = hikashop_get('class.address');
if(!empty($data->cart->billing_address) && !empty($data->cart->fields)){
	$vars['BILLING_ADDRESS'] = $addressClass->displayAddress($data->cart->fields,$data->cart->billing_address,$view);
}
if(!empty($data->cart->override_shipping_address)) {
	$vars['SHIPPING_ADDRESS'] =  $data->cart->override_shipping_address;
} elseif(!empty($data->order_shipping_id) && !empty($data->cart->shipping_address) && !empty($data->cart->fields)) {
	$vars['SHIPPING_ADDRESS'] = $addressClass->displayAddress($data->cart->fields,$data->cart->shipping_address,$view);
} else {
	$vars['SHIPPING_ADDRESS'] = $vars['BILLING_ADDRESS'];
}

I just updated hikashop and now the html version is not working properly. In the preload you can see near the bottom of the code I have where it builds links for the tracking number based on the format to show in the html version. I've tried a UPS number and a USPS number and for some reason since I updated hikashop this is not working anymore. There just nothing there where it is supposed to be (the {VAR:TRACKING} in the html version). What's changed here?

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235171

Hi,

I would say that you should use $data->cart->trackingnumber instead of $data->trackingnumber
Because it's highly possible that $data->trackingnumber is empty.
The variables in $data comes from the data that is being saved by your action on the order. But $data->cart comes from the data stored in the database for your order.
So if you're not currently saving the tracking number in the database, the variable won't be in $data but it will be in $data->cart.

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

  • Posts: 128
  • Thank you received: 3
8 years 7 months ago #235181

Hey nicolas,
I tried $data->cart->trackingnumber but still nothing. I looked at my database tables. After, I create my shipment and get my tracking number I edit the appropriate order in the backend and enter my tracking number into the text field. I noticed that it is being stored in the hikashop_order table. What I can't understand is why this worked perfect before I updated hikashop and joomla and now nothing.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235208

Hi,

Do you still have the column of the custom field in the hikashop_order table ?
So after you edit the field and enter the tracking code and save, you don't see it in the details of your order ?

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

  • Posts: 128
  • Thank you received: 3
8 years 7 months ago #235269

Yes the custom field is still in my table and yes it does save the number in the backend after i edit it and i can see the changes

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235270

Then, if the column name of the custom field is trackingnumber and that the value is stored in that column of hikashop_order in the database, the code using $data->cart->trackingnumber should definitely find it.
So the problem must be somewhere else. But I guess it will require debugging the custom code added to the preload to find out the root of the issue.

The following user(s) said Thank You: deuce4884

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

  • Posts: 128
  • Thank you received: 3
8 years 7 months ago #235355

Finally, figured out what was going on with this. I had only set up this code in the condition that there was multiple shipping methods selected and that was all I had tested before so, when I tested an order where there was only one shipping method it wasn't working. I ended up having the following code

$tracking_link = array();
$tracking = array();
if(!empty($data->cart->order_shipping_id)) {
	$shippingClass = hikashop_get('class.shipping');
	if(!empty($data->cart->order_shipping_method)) {
		if(!is_numeric($data->cart->order_shipping_id)){
			$shipping_name = $shippingClass->getShippingName($data->cart->order_shipping_method, $data->cart->order_shipping_id);
			$vars['SHIPPING'] = $shipping_name;
			$vars['SHIPPING_TXT'] = $vars['SHIPPING'];
            if(strpos($shipping_name,'FedEx') !== false){
            	$tracking_link['FedEx']='<a href="http://www.fedex.com/Tracking?action=track&tracknumbers=';
            }
            if(strpos($shipping_name,'UPS') !== false){
            	$tracking_link['UPS']='<a href="http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=';
            }
            if(strpos($shipping_name,'USPS') !== false){
            	$tracking_link['USPS']='<a href="https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=';
            }
			if(!empty($data->cart->trackingnumber)){
				$tracking_number = explode(',',$data->cart->trackingnumber);
				foreach($tracking_number as $value){
                  if(strlen($value) <= 14){
                      $tracking['FedEx']=$value;
                  }
				  if(substr($value,0,2) === '1Z' && strlen($value) <= 18){
                      $tracking['UPS']=$value;
                  }
				  if(substr($value,0,1) === '9' && strlen($value) <= 22){
                      $tracking['USPS']=$value;
                  }
				}
				$tracking_array=array_combine(array_intersect_key($tracking_link,$tracking),array_intersect_key($tracking,$tracking_link));
				$vars['SHIPPING'] .= '<p>Your tracking numbers are:</p><ul>';
				foreach($tracking_array as $key=>$value){
					$vars['SHIPPING'] .= '<li>'.$key.$value.'">'.$value.'</a>';
				}
				$vars['SHIPPING'] .= '</ul>';
			}
		}else{
			$shipping = $shippingClass->get($data->cart->order_shipping_id);
			$vars['SHIPPING'] = $shipping->shipping_name;
			$vars['SHIPPING_TXT'] = $vars['SHIPPING'];
			if(strpos($shipping->shipping_name,'FedEx') !== false){
            	$tracking_link['FedEx']='<a href="http://www.fedex.com/Tracking?action=track&tracknumbers=';
            }
            if(strpos($shipping->shipping_name,'UPS') !== false){
            	$tracking_link['UPS']='<a href="http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=';
            }
            if(strpos($shipping->shipping_name,'USPS') !== false){
            	$tracking_link['USPS']='<a href="https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=';
            }
			if(!empty($data->cart->trackingnumber)){
				$tracking_number = explode(',',$data->cart->trackingnumber);
				foreach($tracking_number as $value){
                  if(strlen($value) <= 14){
                      $tracking['FedEx']=$value;
                  }
				  if(substr($value,0,2) === '1Z' && strlen($value) <= 18){
                      $tracking['UPS']=$value;
                  }
				  if(substr($value,0,1) === '9' && strlen($value) <= 22){
                      $tracking['USPS']=$value;
                  }
				}
				$tracking_array=array_combine(array_intersect_key($tracking_link,$tracking),array_intersect_key($tracking,$tracking_link));
				$vars['SHIPPING'] .= '<p>Your tracking numbers are:</p><ul>';
				foreach($tracking_array as $key=>$value){
					$vars['SHIPPING'] .= '<li>'.$key.$value.'">'.$value.'</a>';
				}
				$vars['SHIPPING'] .= '</ul>';
			}
		}
	} else {
		$shippings_data = array();
		$shipping_ids = explode(';', $data->cart->order_shipping_id);
		$shippingClass = hikashop_get('class.shipping');
		foreach($shipping_ids as $key) {
			$shipping_data = '';
			list($k, $w) = explode('@', $key);
			$shipping_id = $k;
			if(isset($data->cart->shippings[$shipping_id])) {
				$shipping = $data->cart->shippings[$shipping_id];
				$shipping_data = $shipping->shipping_name;
			} else {
				foreach($data->cart->products as $order_product) {
					if($order_product->order_product_shipping_id == $key) {
						if(!is_numeric($order_product->order_product_shipping_id)){
							$shipping_name = $shippingClass->getShippingName($order_product->order_product_shipping_method, $shipping_id);
							$shipping_data = $shipping_name;
						}else{
							$shipping_method_data = $shippingClass->get($shipping_id);
							$shipping_data = $shipping_method_data->shipping_name;
						}
						break;
					}
				}
				if(empty($shipping_data))
					$shipping_data = '[ ' . $key . ' ]';
			}
			if(isset($data->cart->order_shipping_params->prices[$key])) {
				$price_params = $data->cart->order_shipping_params->prices[$key];
				if($config->get('price_with_tax')){
					$shipping_data .= ' (' . $currencyHelper->format($price_params->price_with_tax, $data->cart->order_currency_id) . ')';
				}else{
					$shipping_data .= ' (' . $currencyHelper->format($price_params->price_with_tax - @$price_params->tax, $data->cart->order_currency_id) . ')';
				}
			}
			$shippings_data[] = $shipping_data;
		}
		if(!empty($shippings_data)) {
			$vars['SHIPPING'] = '<ul><li>'.implode('</li><li>', $shippings_data).'</li></ul>';
			$vars['SHIPPING_TXT'] = ' - ' . implode("\r\n - ", $shippings_data);
			foreach($shippings_data as $ship_method){
				if(strpos($ship_method,'FedEx') !== false){
					$tracking_link['FedEx']='<a href="http://www.fedex.com/Tracking?action=track&tracknumbers=';
				}
				if(strpos($ship_method,'UPS') !== false){
					$tracking_link['UPS']='<a href="http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=';
				}
				if(strpos($ship_method,'USPS') !== false){
					$tracking_link['USPS']='<a href="https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=';
				}
				
			}
			if(!empty($data->cart->trackingnumber)){
				$tracking_number = explode(',',$data->cart->trackingnumber);
				foreach($tracking_number as $value){
                  if(strlen($value) <= 14){
                      $tracking['FedEx']=$value;
                  }
				  if(substr($value,0,2) === '1Z' && strlen($value) <= 18){
                      $tracking['UPS']=$value;
                  }
				  if(substr($value,0,1) === '9' && strlen($value) <= 22){
                      $tracking['USPS']=$value;
                  }
				}
				$tracking_array=array_combine(array_intersect_key($tracking_link,$tracking),array_intersect_key($tracking,$tracking_link));
				$vars['SHIPPING'] .= '<p>Your tracking numbers are:</p><ul>';
				foreach($tracking_array as $key=>$value){
					$vars['SHIPPING'] .= '<li>'.$key.$value.'">'.$value.'</a>';
				}
				$vars['SHIPPING'] .= '</ul>';
			}
		}
	}
	unset($shippingClass);
} else {
	$vars['SHIPPING'] = '';
}

Thanks for all your help on this issue. Just a dumb mistake on my part

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

Time to create page: 0.080 seconds
Powered by Kunena Forum