當前位置: 首頁>>代碼示例>>PHP>>正文


PHP producthelper::getVatRates方法代碼示例

本文整理匯總了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;
 }
開發者ID:,項目名稱:,代碼行數:65,代碼來源:


注:本文中的producthelper::getVatRates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。