本文整理汇总了PHP中producthelper::getVatRates方法的典型用法代码示例。如果您正苦于以下问题:PHP producthelper::getVatRates方法的具体用法?PHP producthelper::getVatRates怎么用?PHP producthelper::getVatRates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类producthelper
的用法示例。
在下文中一共展示了producthelper::getVatRates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyCalculation
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;
}