当前位置: 首页>>代码示例>>PHP>>正文


PHP CCatalogProduct::GetNearestQuantityPrice方法代码示例

本文整理汇总了PHP中CCatalogProduct::GetNearestQuantityPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogProduct::GetNearestQuantityPrice方法的具体用法?PHP CCatalogProduct::GetNearestQuantityPrice怎么用?PHP CCatalogProduct::GetNearestQuantityPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCatalogProduct的用法示例。


在下文中一共展示了CCatalogProduct::GetNearestQuantityPrice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetMEssage

             $countField = " ";
             $balance = " ";
             $active = GetMEssage('SPS_PRODUCT_NO_ACTIVE');
             $act = GetMessage("SPS_CAN_BUY_NOT_PRODUCT");
         }
         $row->AddField("ACT", $act);
         $row->AddField("QUANTITY", $countField);
         $row->AddField("BALANCE", $balance);
         $row->AddField("ACTIVE", $active);
     }
 } else {
     $fieldValue = "";
     $nearestQuantity = $QUANTITY;
     $arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups, "N", array(), $LID, $arDiscountCoupons);
     if (!$arPrice || count($arPrice) <= 0) {
         if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups)) {
             $arPrice = CCatalogProduct::GetOptimalPrice($arItems["ID"], $nearestQuantity, $arBuyerGroups, "N", array(), $LID, $arDiscountCoupons);
         }
     }
     if (!$arPrice || count($arPrice) <= 0) {
         $fieldValue = "&nbsp;";
     } else {
         $currentPrice = $arPrice["PRICE"]["PRICE"];
         $currentBasePrice = $arPrice["PRICE"]["PRICE"];
         if ($arPrice["PRICE"]["VAT_INCLUDED"] == "N" && DoubleVal($arPrice["PRICE"]["VAT_RATE"]) > 0) {
             $currentPrice = (1 + DoubleVal($arPrice["PRICE"]["VAT_RATE"])) * $currentPrice;
         }
         $currentDiscount = 0.0;
         if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0) {
             if ($arPrice["DISCOUNT"]["VALUE_TYPE"] == "F") {
                 if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"]) {
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:product_search.php

示例2: OrderProduct


//.........这里部分代码省略.........
     }
     if (!($arCatalogProduct = static::getHitCache('CATALOG_PRODUCT', $productID))) {
         $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY', 'WEIGHT', 'WIDTH', 'HEIGHT', 'LENGTH', 'BARCODE_MULTI', 'TYPE'));
         if ($arCatalogProduct = $rsProducts->Fetch()) {
             static::setHitCache('CATALOG_PRODUCT', $productID, $arCatalogProduct);
         }
         unset($rsProducts);
     }
     if (!empty($arCatalogProduct) && is_array($arCatalogProduct)) {
         $arCatalogProduct["QUANTITY"] = (double) $arCatalogProduct["QUANTITY"];
         if ($arParams["CHECK_QUANTITY"] == "Y") {
             if ('Y' != $arCatalogProduct["CAN_BUY_ZERO"] && 'Y' == $arCatalogProduct["QUANTITY_TRACE"] && ($arCatalogProduct["QUANTITY"] <= 0 || $quantity > $arCatalogProduct["QUANTITY"])) {
                 return $arResult;
             }
         }
     } else {
         return $arResult;
     }
     if ($adminSection) {
         CCatalogDiscountSave::SetDiscountUserID($intUserID);
     }
     $productHash = array('MODULE' => 'catalog', 'PRODUCT_ID' => $productID, 'BASKET_ID' => $arParams['BASKET_ID']);
     $arCoupons = DiscountCouponsManager::getForApply(array(), $productHash, true);
     if (!empty($arCoupons)) {
         $arCoupons = array_keys($arCoupons);
     }
     $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
     $currentUseDiscount = CCatalogProduct::getUseDiscount();
     CCatalogProduct::setUseDiscount($arParams['CHECK_DISCOUNT'] == 'Y');
     CCatalogProduct::setPriceVatIncludeMode(true);
     CCatalogProduct::setUsedCurrency($arParams['CURRENCY']);
     $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $arParams['RENEWAL'], array(), $adminSection ? $strSiteID : false, $arCoupons);
     if (empty($arPrice)) {
         if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $userGroups)) {
             $quantity = $nearestQuantity;
             $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $arParams['RENEWAL'], array(), $adminSection ? $strSiteID : false, $arCoupons);
         }
     }
     CCatalogProduct::clearUsedCurrency();
     CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
     CCatalogProduct::setUseDiscount($currentUseDiscount);
     unset($userGroups, $currentUseDiscount, $currentVatMode);
     if ($adminSection) {
         CCatalogDiscountSave::ClearDiscountUserID();
     }
     if (empty($arPrice)) {
         return $arResult;
     }
     $arDiscountList = array();
     if (empty($arPrice['DISCOUNT_LIST']) && !empty($arPrice['DISCOUNT']) && is_array($arPrice['DISCOUNT'])) {
         $arPrice['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']);
     }
     if (!empty($arPrice['DISCOUNT_LIST'])) {
         $appliedCoupons = array();
         foreach ($arPrice['DISCOUNT_LIST'] as &$arOneDiscount) {
             $arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'COUPON_TYPE' => '', 'USE_COUPONS' => isset($arOneDiscount['USE_COUPONS']) ? $arOneDiscount['USE_COUPONS'] : 'N', 'MODULE_ID' => isset($oneDiscount['MODULE_ID']) ? $oneDiscount['MODULE_ID'] : 'catalog', 'TYPE' => $arOneDiscount['TYPE'], 'VALUE' => $arOneDiscount['VALUE'], 'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'], 'MAX_VALUE' => $arOneDiscount['VALUE_TYPE'] == Catalog\DiscountTable::VALUE_TYPE_PERCENT ? $arOneDiscount['MAX_DISCOUNT'] : 0, 'CURRENCY' => $arOneDiscount['CURRENCY'], 'HANDLERS' => isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array());
             if (!empty($arOneDiscount['COUPON'])) {
                 $arOneList['USE_COUPONS'] = 'Y';
                 $arOneList['COUPON'] = $arOneDiscount['COUPON'];
                 $arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME'];
                 $appliedCoupons[] = $arOneDiscount['COUPON'];
             }
             $arDiscountList[] = $arOneList;
         }
         unset($arOneList, $arOneDiscount);
         if (!empty($appliedCoupons)) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:product_provider.php

示例3: CatalogRecurringCallback

function CatalogRecurringCallback($productID, $userID)
{
    global $APPLICATION;
    global $DB;
    $productID = intval($productID);
    if ($productID <= 0) {
        return false;
    }
    $userID = intval($userID);
    if ($userID <= 0) {
        return false;
    }
    $arProduct = CCatalogProduct::GetByID($productID);
    if (!$arProduct) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_PRODUCT")), "NO_PRODUCT");
        return false;
    }
    if ($arProduct["PRICE_TYPE"] == "T") {
        $arProduct = CCatalogProduct::GetByID($arProduct["TRIAL_PRICE_ID"]);
        if (!$arProduct) {
            $APPLICATION->ThrowException(str_replace("#TRIAL_ID#", $productID, str_replace("#ID#", $arProduct["TRIAL_PRICE_ID"], Loc::getMessage("I_NO_TRIAL_PRODUCT"))), "NO_PRODUCT_TRIAL");
            return false;
        }
    }
    $productID = intval($arProduct["ID"]);
    if ($arProduct["PRICE_TYPE"] != "R") {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_NOT_SUBSCR")), "NO_IBLOCK_SUBSCR");
        return false;
    }
    $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
    if (!($arIBlockElement = $dbIBlockElement->GetNext())) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
        return false;
    }
    if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
        $arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
        if (empty($arUserRights)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        } elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        }
    } else {
        if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        }
    }
    $arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
    if ($arCatalog["SUBSCRIPTION"] != "Y") {
        $APPLICATION->ThrowException(str_replace("#ID#", $arIBlockElement["IBLOCK_ID"], Loc::getMessage("I_CATALOG_NOT_SUBSCR")), "NOT_SUBSCRIPTION");
        return false;
    }
    if ($arProduct["CAN_BUY_ZERO"] != "Y" && ($arProduct["QUANTITY_TRACE"] == "Y" && doubleval($arProduct["QUANTITY"]) <= 0)) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_SOLD")), "PRODUCT_END");
        return false;
    }
    $arUserGroups = CUser::GetUserGroup($userID);
    $arUserGroups = array_values(array_unique($arUserGroups));
    CCatalogDiscountSave::Disable();
    $arPrice = CCatalogProduct::GetOptimalPrice($productID, 1, $arUserGroups, "Y");
    if (empty($arPrice)) {
        if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, 1, $arUserGroups)) {
            $quantity = $nearestQuantity;
            $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $arUserGroups, "Y");
        }
    }
    CCatalogDiscountSave::Enable();
    if (empty($arPrice)) {
        return false;
    }
    $currentPrice = $arPrice["PRICE"]["PRICE"];
    $currentDiscount = 0.0;
    //SIGURD: logic change. see mantiss 5036.
    // discount applied to a final price with VAT already included.
    if (doubleval($arPrice['PRICE']['VAT_RATE']) > 0) {
        $currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
    }
    $arDiscountList = array();
    if (!empty($arPrice["DISCOUNT_LIST"])) {
        $dblStartPrice = $currentPrice;
        foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
            switch ($arOneDiscount['VALUE_TYPE']) {
                case CCatalogDiscount::TYPE_FIX:
                    if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                        $currentDiscount = $arOneDiscount['VALUE'];
                    } else {
                        $currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                    }
                    $currentPrice = $currentPrice - $currentDiscount;
                    break;
                case CCatalogDiscount::TYPE_PERCENT:
                    $currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
                    if (0 < $arOneDiscount['MAX_DISCOUNT']) {
                        if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                            $dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
                        } else {
                            $dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                        }
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:include.php

示例4: OrderProduct


//.........这里部分代码省略.........
					&& 'Y' == $arCatalogProduct["QUANTITY_TRACE"]
					&& ($arCatalogProduct["QUANTITY"] <= 0 || $quantity > $arCatalogProduct["QUANTITY"])
				)
				{
					return $arResult;
				}
			}
		}
		else
		{
			return $arResult;
		}

		if (0 < $intUserID)
		{
			$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
			CCatalogDiscountSave::SetDiscountUserID($intUserID);
		}
		else
		{
			$arCoupons = CCatalogDiscountCoupon::GetCoupons();
		}

		$userGroups = ($intUserID > 0 ? $arUserCache[$intUserID] : $USER->GetUserGroupArray());
		$currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
		$currentUseDiscount = CCatalogProduct::getUseDiscount();
		CCatalogProduct::setUseDiscount($arParams['CHECK_DISCOUNT'] == 'Y');
		CCatalogProduct::setPriceVatIncludeMode(true);
		CCatalogProduct::setUsedCurrency($arParams['CURRENCY']);
		$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);

		if (empty($arPrice))
		{
			if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $userGroups))
			{
				$quantity = $nearestQuantity;
				$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);
			}
		}
		CCatalogProduct::clearUsedCurrency();
		CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
		CCatalogProduct::setUseDiscount($currentUseDiscount);
		unset($userGroups, $currentUseDiscount, $currentVatMode);
		if (0 < $intUserID)
		{
			CCatalogDiscountSave::ClearDiscountUserID();
		}

		if (empty($arPrice))
		{
			return $arResult;
		}

		$arDiscountList = array();
		$arCouponList = array();

		if (!empty($arPrice["DISCOUNT_LIST"]))
		{
			foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount)
			{
				$arOneList = array(
					'ID' => $arOneDiscount['ID'],
					'NAME' => $arOneDiscount['NAME'],
					'COUPON' => '',
					'COUPON_TYPE' => '',
					'MODULE_ID' => (isset($oneDiscount['MODULE_ID']) ? $oneDiscount['MODULE_ID'] : 'catalog'),
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:67,代码来源:product_provider.php

示例5: OrderProduct

 public static function OrderProduct($arParams)
 {
     if (!is_set($arParams, "RENEWAL") || $arParams["RENEWAL"] != "Y") {
         $arParams["RENEWAL"] = "N";
     }
     if (!is_set($arParams, "USER_ID") || IntVal($arParams["USER_ID"]) <= 0) {
         $arParams["USER_ID"] = 0;
     }
     if (!is_set($arParams["SITE_ID"])) {
         $arParams["SITE_ID"] = false;
     }
     global $USER;
     global $DB;
     $productID = intval($arParams["PRODUCT_ID"]);
     $quantity = doubleval($arParams["QUANTITY"]);
     $renewal = $arParams["RENEWAL"] == "Y" ? "Y" : "N";
     $strSiteID = $arParams["SITE_ID"];
     $intUserID = intval($arParams["USER_ID"]);
     if (0 > $intUserID) {
         $intUserID = 0;
     }
     $arResult = array();
     static $arUserCache = array();
     if (0 < $intUserID) {
         if (!array_key_exists($intUserID, $arUserCache)) {
             $rsUsers = CUser::GetList($by = 'ID', $order = 'DESC', array("ID_EQUAL_EXACT" => $intUserID), array('FIELDS' => array('ID')));
             if ($arUser = $rsUsers->Fetch()) {
                 $arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
             } else {
                 $intUserID = 0;
                 return $arResult;
             }
         }
         $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSION" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
         if (!($arProduct = $dbIBlockElement->GetNext())) {
             return $arResult;
         }
         if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE")) {
             $arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID);
             if (empty($arUserRights)) {
                 return $arResult;
             } elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
                 return $arResult;
             }
         } else {
             if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID)) {
                 return $arResult;
             }
         }
     } else {
         $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "Y", "MIN_PERMISSION" => "R"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
         if (!($arProduct = $dbIBlockElement->GetNext())) {
             return $arResult;
         }
     }
     if ($arCatalogProduct = CCatalogProduct::GetByID($productID)) {
         if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) < doubleVal($quantity))) {
             return $arResult;
         }
     } else {
         return $arResult;
     }
     if (0 < $intUserID) {
         $arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
         CCatalogDiscountSave::SetDiscountUserID($intUserID);
     } else {
         $arCoupons = CCatalogDiscountCoupon::GetCoupons();
     }
     $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
     if (empty($arPrice)) {
         if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())) {
             $quantity = $nearestQuantity;
             $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, 0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray(), $renewal, array(), 0 < $intUserID ? $strSiteID : false, $arCoupons);
         }
     }
     if (empty($arPrice)) {
         if (0 < $intUserID) {
             CCatalogDiscountSave::ClearDiscountUserID();
         }
         return $arResult;
     }
     $boolDiscountVat = 'N' != COption::GetOptionString('catalog', 'discount_vat', 'Y');
     $currentPrice = $arPrice["PRICE"]["PRICE"];
     $currentDiscount = 0.0;
     if ($boolDiscountVat) {
         if ('N' == $arPrice['PRICE']['VAT_INCLUDED']) {
             $currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
             $arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
         }
     } else {
         if ('Y' == $arPrice['PRICE']['VAT_INCLUDED']) {
             $currentPrice /= 1 + $arPrice['PRICE']['VAT_RATE'];
             $arPrice['PRICE']['VAT_INCLUDED'] = 'N';
         }
     }
     $arDiscountList = array();
     $arCouponList = array();
     if (!empty($arPrice["DISCOUNT_LIST"])) {
         $dblStartPrice = $currentPrice;
         foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:product_provider.php

示例6: OrderProduct


//.........这里部分代码省略.........
		{
			$arCatalogProduct["QUANTITY"] = (double)$arCatalogProduct["QUANTITY"];
			if ($arParams["CHECK_QUANTITY"] == "Y")
			{
				if (
					'Y' != $arCatalogProduct["CAN_BUY_ZERO"]
					&& 'Y' == $arCatalogProduct["QUANTITY_TRACE"]
					&& ($arCatalogProduct["QUANTITY"] <= 0 || $quantity > $arCatalogProduct["QUANTITY"])
				)
				{
					return $arResult;
				}
			}
		}
		else
		{
			return $arResult;
		}

		if (0 < $intUserID)
		{
			$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
			CCatalogDiscountSave::SetDiscountUserID($intUserID);
		}
		else
		{
			$arCoupons = CCatalogDiscountCoupon::GetCoupons();
		}

		$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray()), $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);

		if (empty($arPrice))
		{
			if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray())))
			{
				$quantity = $nearestQuantity;
				$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, (0 < $intUserID ? $arUserCache[$intUserID] : $USER->GetUserGroupArray()), $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);
			}
		}

		if (empty($arPrice))
		{
			if (0 < $intUserID)
			{
				CCatalogDiscountSave::ClearDiscountUserID();
			}
			return $arResult;
		}

		$boolDiscountVat = ('N' != COption::GetOptionString('catalog', 'discount_vat', 'Y'));

		$currentPrice = $arPrice["PRICE"]["PRICE"];
		$currentDiscount = 0.0;

		if ($boolDiscountVat)
		{
			if ('N' == $arPrice['PRICE']['VAT_INCLUDED'])
			{
				$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
				$arPrice['PRICE']['VAT_INCLUDED'] = 'Y';
			}
		}
		else
		{
			if ('Y' == $arPrice['PRICE']['VAT_INCLUDED'])
			{
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:67,代码来源:product_provider.php

示例7: CatalogBasketCustomCallback

/**
 * Функция обратного вызова для корзины
 * аналогична функции CatalogBasketCallback за исключением использования одной определенной цены для конкретного города
 * 
 * @param $productID
 * @param $quantity
 * @param $renewal
 */
function CatalogBasketCustomCallback($productID, $quantity = 0, $renewal = "N")
{
	global $USER;

	$productID = IntVal($productID);
	$quantity = DoubleVal($quantity);
	$renewal = (($renewal == "Y") ? "Y" : "N");

	$arResult = array();

	if ($arCatalogProduct = CCatalogProduct::GetByID($productID))
	{
		if ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && DoubleVal($arCatalogProduct["QUANTITY"])<=0)
			return $arResult;
		
	}

	$dbIBlockElement = CIBlockElement::GetList(
			array(),
			array(
					"ID" => $productID,
					"ACTIVE_DATE" => "Y",
					"ACTIVE" => "Y",
					"CHECK_PERMISSIONS" => "Y"
				)
		);
	$arProduct = $dbIBlockElement->GetNext();
	$arCatalog = CCatalog::GetByID($arProduct["IBLOCK_ID"]);
	if ($arCatalog["SUBSCRIPTION"] == "Y")
	{
		$quantity = 1;
	}
	$rs = CPrice::GetList(
		array(),
		array("CATALOG_GROUP_NAME" => GetCityPrice(), "PRODUCT_ID" => $productID), false, false);
	
	$ar = $rs -> Fetch();

	$arPrice = array();
	$arPrice[] = array(
		"ID" => $ar["ID"],
		"PRICE" => $ar["PRICE"],
		"CURRENCY" => $ar["CURRENCY"],
		"CATALOG_GROUP_ID" => $ar["CATALOG_GROUP_ID"]
	);

	$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER -> GetUserGroupArray(), $renewal, $arPrice);

	if (!$arPrice || count($arPrice) <= 0)
	{
		if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $USER->GetUserGroupArray()))
		{
			$quantity = $nearestQuantity;
			$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $USER->GetUserGroupArray(), $renewal);
		}
	}

	if (!$arPrice || count($arPrice) <= 0)
	{
		return $arResult;
	}

	$currentPrice = $arPrice["PRICE"]["PRICE"];
	$currentDiscount = 0.0;

	//SIGURD: logic change. see mantiss 5036.
	// discount applied to a final price with VAT already included.
	if ($arPrice['PRICE']['VAT_INCLUDED'] == 'N')
	{
		if(DoubleVal($arPrice['PRICE']['VAT_RATE']) > 0)
		{
			$currentPrice *= (1 + $arPrice['PRICE']['VAT_RATE']);
			$arPrice['PRICE']['VAT_INCLUDED'] = 'y';
		}
	}

	if (isset($arPrice["DISCOUNT"]) && count($arPrice["DISCOUNT"]) > 0)
	{
		if ($arPrice["DISCOUNT"]["VALUE_TYPE"]=="F")
		{
			if ($arPrice["DISCOUNT"]["CURRENCY"] == $arPrice["PRICE"]["CURRENCY"])
				$currentDiscount = $arPrice["DISCOUNT"]["VALUE"];
			else
				$currentDiscount = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT"]["VALUE"], $arPrice["DISCOUNT"]["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
		}
		else
			$currentDiscount = $currentPrice * $arPrice["DISCOUNT"]["VALUE"] / 100.0;

		$currentDiscount = roundEx($currentDiscount, SALE_VALUE_PRECISION);

		if (DoubleVal($arPrice["DISCOUNT"]["MAX_DISCOUNT"]) > 0)
		{
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:alba,代码行数:101,代码来源:basket.php


注:本文中的CCatalogProduct::GetNearestQuantityPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。