Hi admins,I have tried to use $this->tax->calculate(...
.
It doesn't work.Here is my full code,in case i was missing something within the code.
public function onControllerCommonHeader_InitData()
{
$that=$this->baseObject;
$that->loadLanguage('total/total');
$that->loadLanguage('blocks/cart');
$that->data['heading_title'] = $that->language->get('heading_title');
$that->data['text_subtotal'] = $that->language->get('text_subtotal');
$that->data['text_empty'] = $that->language->get('text_empty');
$that->data['text_remove'] = $that->language->get('text_remove');
$that->data['text_confirm'] = $that->language->get('text_confirm');
$that->data['text_view'] = $that->language->get('text_view');
$that->data['text_checkout'] = $that->language->get('text_checkout');
$that->data['text_items'] = $that->language->get('text_items');
$that->data['text_total'] = $that->language->get('text_total');
$that->data['view'] = $that->html->getURL('checkout/cart');
$that->data['remove'] = $that->html->getURL('r/checkout/cart');
$that->data['checkout'] = $that->html->getURL('checkout/shipping');
$products = array();
$qty = 0;
$resource = new AResource('image');
$results=$that->extensions->hkgetProducts($cart);
foreach ($results as $result) {
$option_data = array();
$thumbnail = $resource->getMainThumb('products',
$result['product_id'],
$that->config->get('config_image_product_width'),
$that->config->get('config_image_product_height'),true);
foreach ($result['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => $option['value']
);
}
$qty += $result['quantity'];
$products[] = array(
'key' => $result['key'],
'name' => $result['name'],
'option' => $option_data,
'quantity' => $result['quantity'],
'stock' => $result['stock'],
'price' => $that->currency->format($that->tax->calculate($result['price'], $result['tax_class_id'], $that->config->get('config_tax'))),
'href' => $that->html->getSEOURL('product/product','&product_id=' . $result['product_id'],true),
'thumb' => $thumbnail,
);
}
$that->data['products'] = $products;
$that->data['total_qty'] = $qty;
$display_totals = $that->extensions->hkbuildTotalDisplay($cart);
$that->data['totals'] = $display_totals['total_data'];
$that->data['subtotal'] = $that->currency->format($this->tax->calculate($display_totals['total'], $result['tax_class_id'], $that->config->get('config_tax')));
$that->data['taxes'] = $display_totals['taxes'];
$that->data['ajax'] = $that->config->get('cart_ajax');
$that->view->batchAssign($that->data);
$this->processTemplate();
}