Esempio n. 1
0
 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;
 }
Esempio n. 2
0
    if ($product_price >= $texpricemin && $product_price <= $texpricemax && $count > 0) {
        $k++;
        $count--;
        ?>
			<tr>
				<td>
					<?php 
        $thum_image = $producthelper->getProductImage($row->product_id, $link, $thumbwidth, $thumbheight);
        echo "<div class='mod_redshop_pricefilter'>";
        if ($image) {
            echo $thum_image . "<br>";
        }
        echo "<a href='" . $link . "'>" . $row->product_name . "</a><br>";
        $productArr = $producthelper->getProductNetPrice($row->product_id);
        $product_price_discount = $productArr['productPrice'] + $productArr['productVat'];
        $taxexempt_addtocart = $producthelper->taxexempt_addtocart();
        if (!$row->not_for_sale && $show_price && $taxexempt_addtocart) {
            if (SHOW_PRICE && (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE)) {
                if (!$product_price) {
                    $product_price_dis = $producthelper->getPriceReplacement($product_price);
                } else {
                    $product_price_dis = $producthelper->getProductFormattedPrice($product_price);
                }
                $pricetext = "";
                $disply_text = "<div class='mod_redproducts_price'>" . $product_price_dis . "</div>";
                if ($row->product_on_sale && $product_price_discount > 0) {
                    if ($product_price > $product_price_discount) {
                        $disply_text = "";
                        $s_price = $product_price - $product_price_discount;
                        $tmpprcie = $product_price_discount;
                        if ($show_discountpricelayout) {