Then, you need to move the block of code which loads the $data object before where you want to use it.
I'm talking about that big block of code:
<?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 = '<a href="'.$order_url.'">'. $url.'</a>';
}
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;
//$tax = $data->cart->order_subtotal - $data->cart->order_subtotal_no_vat;
$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';
}
?>