/** * Calculates the tax totals for the order * using the array of items in the order object * * @return unknown_type */ function calculateTaxTotals() { $t = new K2StoreTax(); $tax_total = 0.0; $items = $this->getItems(); if (!is_array($items)) { $this->order_tax = $tax_total; return; } foreach ($items as $key => $item) { $orderitem_tax = 0; //$product_tax_rate = K2StorePrices::getItemTax($item->product_id); //$orderitem_tax += $product_tax_rate * $item->orderitem_final_price; // track the total tax for this item $orderitem_tax += $t->getProductTax($item->orderitem_final_price, $item->product_id); $item->orderitem_tax = $orderitem_tax; // track the running total $tax_total += $item->orderitem_tax; } $this->order_tax = $tax_total; }
public static function getTotal() { $total = 0; JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_k2store/models'); $model = JModelLegacy::getInstance('Mycart', 'K2StoreModel'); $products = $model->getDataNew(); $t = new K2StoreTax(); $tax_amount = 0; foreach ($products as $product) { //calculate the tax $tax_amount = $t->getProductTax($product['price'], $product['product_id']); if ($tax_amount) { $total += ($product['price'] + $tax_amount) * $product['quantity']; } else { $total += $product['price'] * $product['quantity']; } } return $total; }