public function modifyCalculation($cart) { $producthelper = new producthelper(); $calArr = $this->_carthelper->calculation($cart); $cart['product_subtotal'] = $calArr[1]; $session = JFactory::getSession(); $discount_amount = 0; $voucherDiscount = 0; $couponDiscount = 0; $discount_excl_vat = 0; $totaldiscount = 0; if (DISCOUNT_ENABLE == 1) { $discount_amount = $producthelper->getDiscountAmount($cart); if ($discount_amount > 0) { $cart = $this->_session->get('cart'); } } $cart['cart_discount'] = $discount_amount; if (array_key_exists('voucher', $cart)) { $voucherDiscount = $this->_carthelper->calculateDiscount('voucher', $cart['voucher']); } $cart['voucher_discount'] = $voucherDiscount; if (array_key_exists('coupon', $cart)) { $couponDiscount = $this->_carthelper->calculateDiscount('coupon', $cart['coupon']); } $cart['coupon_discount'] = $couponDiscount; $codeDsicount = $voucherDiscount + $couponDiscount; $totaldiscount = $cart['cart_discount'] + $codeDsicount; $calArr = $this->_carthelper->calculation($cart); $tax = $calArr[5]; $discountVAT = 0; $chktag = $producthelper->taxexempt_addtocart(); if (VAT_RATE_AFTER_DISCOUNT && !APPLY_VAT_ON_DISCOUNT && !empty($chktag)) { if (isset($cart['discount_tax']) && !empty($cart['discount_tax'])) { $discountVAT = $cart['discount_tax']; $calArr[1] = $calArr[1] - $cart['discount_tax']; $tax = $tax - $discountVAT; } else { $vatData = $producthelper->getVatRates(); if (isset($vatData->tax_rate) && !empty($vatData->tax_rate)) { $productPriceExclVAT = $cart['product_subtotal_excl_vat']; $productVAT = $cart['product_subtotal'] - $cart['product_subtotal_excl_vat']; $avgVAT = ($productPriceExclVAT + $productVAT) / $productPriceExclVAT - 1; $discountVAT = $avgVAT * $totaldiscount / (1 + $avgVAT); } } } $cart['total'] = $calArr[0] - $totaldiscount; $cart['subtotal'] = $calArr[1] + $calArr[3] - $totaldiscount; $cart['subtotal_excl_vat'] = $calArr[2] + ($calArr[3] - $calArr[6]) - ($totaldiscount - $discountVAT); if ($cart['total'] <= 0) { $cart['subtotal_excl_vat'] = 0; } $cart['product_subtotal'] = $calArr[1]; $cart['product_subtotal_excl_vat'] = $calArr[2]; $cart['shipping'] = $calArr[3]; $cart['tax'] = $tax; $cart['sub_total_vat'] = $tax + $calArr[6]; $cart['discount_vat'] = $discountVAT; $cart['shipping_tax'] = $calArr[6]; $cart['discount_ex_vat'] = $totaldiscount - $discountVAT; $cart['mod_cart_total'] = $this->_carthelper->GetCartModuleCalc($cart); $session->set('cart', $cart); return $cart; }