本文整理汇总了PHP中CCatalogDiscount::GetDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::GetDiscount方法的具体用法?PHP CCatalogDiscount::GetDiscount怎么用?PHP CCatalogDiscount::GetDiscount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscount
的用法示例。
在下文中一共展示了CCatalogDiscount::GetDiscount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CatalogGetPriceTable
function CatalogGetPriceTable($ID)
{
global $USER;
$ID = (int) $ID;
if ($ID <= 0) {
return false;
}
$arResult = array();
$arPriceGroups = array();
$cacheKey = LANGUAGE_ID . "_" . $USER->GetGroups();
if (isset($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"]) && is_array($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"]) && isset($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey]) && is_array($GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey])) {
$arPriceGroups = $GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey];
} else {
$dbPriceGroupsList = CCatalogGroup::GetList(array("SORT" => "ASC"), array("CAN_ACCESS" => "Y", "LID" => LANGUAGE_ID), array("ID", "NAME_LANG", "SORT"), false, array("ID", "NAME_LANG", "CAN_BUY", "SORT"));
while ($arPriceGroupsList = $dbPriceGroupsList->Fetch()) {
$arPriceGroups[] = $arPriceGroupsList;
$GLOBALS["CATALOG_PRICE_GROUPS_CACHE"][$cacheKey][] = $arPriceGroupsList;
}
}
if (empty($arPriceGroups)) {
return false;
}
$arBorderMap = array();
$arPresentGroups = array();
$bMultiQuantity = False;
$dbPrice = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"), array("PRODUCT_ID" => $ID), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO", "ELEMENT_IBLOCK_ID", "SORT"));
while ($arPrice = $dbPrice->Fetch()) {
CCatalogDiscountSave::Disable();
$arDiscounts = CCatalogDiscount::GetDiscount($ID, $arPrice["ELEMENT_IBLOCK_ID"], $arPrice["CATALOG_GROUP_ID"], $USER->GetUserGroupArray(), "N", SITE_ID, array());
CCatalogDiscountSave::Enable();
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts);
$arPrice["DISCOUNT_PRICE"] = $discountPrice;
if (array_key_exists($arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"], $arBorderMap)) {
$jnd = $arBorderMap[$arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"]];
} else {
$jnd = count($arBorderMap);
$arBorderMap[$arPrice["QUANTITY_FROM"] . "-" . $arPrice["QUANTITY_TO"]] = $jnd;
}
$arResult[$jnd]["QUANTITY_FROM"] = DoubleVal($arPrice["QUANTITY_FROM"]);
$arResult[$jnd]["QUANTITY_TO"] = DoubleVal($arPrice["QUANTITY_TO"]);
if (DoubleVal($arPrice["QUANTITY_FROM"]) > 0 || DoubleVal($arPrice["QUANTITY_TO"]) > 0) {
$bMultiQuantity = True;
}
$arResult[$jnd]["PRICE"][$arPrice["CATALOG_GROUP_ID"]] = $arPrice;
}
$numGroups = count($arPriceGroups);
for ($i = 0; $i < $numGroups; $i++) {
$bNeedKill = True;
for ($j = 0, $intCount = count($arResult); $j < $intCount; $j++) {
if (!array_key_exists($arPriceGroups[$i]["ID"], $arResult[$j]["PRICE"])) {
$arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]] = False;
}
if ($arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]] != false) {
$bNeedKill = False;
}
}
if ($bNeedKill) {
for ($j = 0, $intCount = count($arResult); $j < $intCount; $j++) {
unset($arResult[$j]["PRICE"][$arPriceGroups[$i]["ID"]]);
}
unset($arPriceGroups[$i]);
}
}
return array("COLS" => $arPriceGroups, "MATRIX" => $arResult, "MULTI_QUANTITY" => $bMultiQuantity ? "Y" : "N");
}
示例2: GetOptimalPrice
//.........这里部分代码省略.........
$dblMinPrice = -1;
$arMinPrice = array();
$arMinDiscounts = array();
foreach ($arPrices as &$arPriceList)
{
$arPriceList['VAT_RATE'] = $arVAT['RATE'];
$arPriceList['VAT_INCLUDED'] = $arVAT['VAT_INCLUDED'];
$arPriceList['ORIG_VAT_INCLUDED'] = $arPriceList['VAT_INCLUDED'];
if ($boolDiscountVat)
{
if ('N' == $arPriceList['VAT_INCLUDED'])
{
$arPriceList['PRICE'] *= (1 + $arPriceList['VAT_RATE']);
$arPriceList['VAT_INCLUDED'] = 'Y';
}
}
else
{
if ('Y' == $arPriceList['VAT_INCLUDED'])
{
$arPriceList['PRICE'] /= (1 + $arPriceList['VAT_RATE']);
$arPriceList['VAT_INCLUDED'] = 'N';
}
}
if ($arPriceList["CURRENCY"] == $strBaseCurrency)
$dblCurrentPrice = $arPriceList["PRICE"];
else
$dblCurrentPrice = CCurrencyRates::ConvertCurrency($arPriceList["PRICE"], $arPriceList["CURRENCY"], $strBaseCurrency);
$arDiscounts = CCatalogDiscount::GetDiscount($intProductID, $intIBlockID, $arPriceList["CATALOG_GROUP_ID"], $arUserGroups, $renewal, $siteID, $arDiscountCoupons);
$arDiscSave = array();
$arPriceDiscount = array();
$arResultPrice = array(
'PRICE' => $dblCurrentPrice,
'CURRENCY' => $strBaseCurrency,
);
$arDiscountApply = array();
if (!empty($arDiscounts))
{
CCatalogProduct::__PrimaryDiscountFilter($arDiscounts, $arPriceDiscount, $arDiscSave, $arResultPrice);
if (!empty($arPriceDiscount))
{
foreach ($arPriceDiscount as &$arOnePriority)
{
$boolResultPriority = CCatalogProduct::__CalcOnePriority($arOnePriority, $arDiscountApply, $arResultPrice);
if (!$boolResultPriority)
{
return false;
}
else
{
if (isset($arResultPrice['LAST_DISCOUNT']) && 'Y' == $arResultPrice['LAST_DISCOUNT'])
break;
}
}
if (isset($arOnePriority))
unset($arOnePriority);
}
示例3: GetDiscount
public function GetDiscount($intProductID, $intIBlockID, $arCatalogGroups = array(), $arUserGroups = array(), $strRenewal = "N", $siteID = false, $arDiscountCoupons = false, $boolSKU = true, $boolGetIDS = false)
{
global $DB;
global $APPLICATION;
global $stackCacheManager;
foreach (GetModuleEvents("catalog", "OnGetDiscount", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $intIBlockID, $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, $boolSKU, $boolGetIDS));
if (true !== $mxResult) {
return $mxResult;
}
}
$boolSKU = true === $boolSKU ? true : false;
$boolGetIDS = true === $boolGetIDS ? true : false;
$intProductID = intval($intProductID);
if (0 >= $intProductID) {
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$intIBlockID = intval($intIBlockID);
if (0 >= $intIBlockID) {
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_IBLOCK_ID_ABSENT"), "NO_IBLOCK_ID");
return false;
}
if (isset($arCatalogGroups)) {
if (is_array($arCatalogGroups)) {
array_walk($arCatalogGroups, create_function("&\$item", "\$item=intval(\$item);"));
$arCatalogGroups = array_unique($arCatalogGroups);
} else {
if (intval($arCatalogGroups) . "|" == $arCatalogGroups . "|") {
$arCatalogGroups = array(intval($arCatalogGroups));
} else {
$arCatalogGroups = array();
}
}
} else {
$arCatalogGroups = array();
}
if (!is_array($arUserGroups) && intval($arUserGroups) . "|" == $arUserGroups . "|") {
$arUserGroups = array(intval($arUserGroups));
}
if (!is_array($arUserGroups)) {
$arUserGroups = array();
}
if (!in_array(2, $arUserGroups)) {
$arUserGroups[] = 2;
}
$strRenewal = $strRenewal == "Y" ? "Y" : "N";
if ($siteID === false) {
$siteID = SITE_ID;
}
if ($arDiscountCoupons === false) {
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
}
$arSKU = false;
if ($boolSKU) {
$arSKU = CCatalogSKU::GetProductInfo($intProductID, $intIBlockID);
if (!is_array($arSKU)) {
$boolSKU = false;
}
}
$arResult = array();
$arResultID = array();
$arFilter = array('PRICE_TYPE_ID' => $arCatalogGroups, 'USER_GROUP_ID' => $arUserGroups);
$arDiscountIDs = CCatalogDiscount::__GetDiscountID($arFilter);
if (!empty($arDiscountIDs)) {
$boolGenerate = false;
$arSelect = array("ID", "TYPE", "SITE_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "RENEWAL", "NAME", "SORT", "MAX_DISCOUNT", "VALUE_TYPE", "VALUE", "CURRENCY", "PRIORITY", "LAST_DISCOUNT", "COUPON", "COUPON_ONE_TIME", "COUPON_ACTIVE", 'UNPACK');
$strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
$arFilter = array("ID" => $arDiscountIDs, "SITE_ID" => $siteID, "TYPE" => DISCOUNT_TYPE_STANDART, "ACTIVE" => "Y", "RENEWAL" => $strRenewal, "+<=ACTIVE_FROM" => $strDate, "+>=ACTIVE_TO" => $strDate);
if (is_array($arDiscountCoupons)) {
$arFilter["+COUPON"] = $arDiscountCoupons;
}
$rsPriceDiscounts = CCatalogDiscount::GetList(array(), $arFilter, false, false, $arSelect);
while ($arPriceDiscount = $rsPriceDiscounts->Fetch()) {
if ($arPriceDiscount['COUPON_ACTIVE'] != 'N') {
if (!$boolGenerate) {
$arProduct = array('ID' => $intProductID, 'IBLOCK_ID' => $intIBlockID);
if (!self::__GenerateFields($arProduct)) {
return false;
}
$boolGenerate = true;
}
if (CCatalogDiscount::__Unpack($arProduct, $arPriceDiscount['UNPACK'])) {
unset($arPriceDiscount['UNPACK']);
$arResult[] = $arPriceDiscount;
$arResultID[] = $arPriceDiscount['ID'];
}
}
}
}
if ($boolSKU) {
$arDiscountParent = CCatalogDiscount::GetDiscount($arSKU['ID'], $arSKU['IBLOCK_ID'], $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, false, false);
if (!empty($arDiscountParent)) {
if (empty($arResult)) {
$arResult = $arDiscountParent;
} else {
foreach ($arDiscountParent as &$arOneParentDiscount) {
if (in_array($arOneParentDiscount['ID'], $arResultID)) {
continue;
}
//.........这里部分代码省略.........
示例4: GetItemPrices
public static function GetItemPrices($IBLOCK_ID, $arCatalogPrices, $arItem, $bVATInclude = true, $arCurrencyParams = array(), $USER_ID = 0, $LID = SITE_ID)
{
$arPrices = array();
if (empty($arCatalogPrices) || !is_array($arCatalogPrices))
{
return $arPrices;
}
global $USER;
static $arCurUserGroups = array();
static $strBaseCurrency = '';
if (self::$catalogIncluded === null)
self::$catalogIncluded = \Freetrix\Main\Loader::includeModule('catalog');
if (self::$catalogIncluded)
{
$USER_ID = intval($USER_ID);
$intUserID = $USER_ID;
if (0 >= $intUserID)
$intUserID = $USER->GetID();
if (!isset($arCurUserGroups[$intUserID]))
{
$arUserGroups = (0 < $USER_ID ? CUser::GetUserGroup($USER_ID) : $USER->GetUserGroupArray());
CatalogClearArray($arUserGroups);
$arCurUserGroups[$intUserID] = $arUserGroups;
}
else
{
$arUserGroups = $arCurUserGroups[$intUserID];
}
$boolConvert = false;
$strCurrencyID = '';
if (isset($arCurrencyParams['CURRENCY_ID']) && !empty($arCurrencyParams['CURRENCY_ID']))
{
$boolConvert = true;
$strCurrencyID = $arCurrencyParams['CURRENCY_ID'];
}
if (!$boolConvert && '' == $strBaseCurrency)
$strBaseCurrency = CCurrency::GetBaseCurrency();
$strMinCode = '';
$boolStartMin = true;
$dblMinPrice = 0;
$strMinCurrency = ($boolConvert ? $strCurrencyID : $strBaseCurrency);
CCatalogDiscountSave::Disable();
foreach($arCatalogPrices as $key => $value)
{
if($value["CAN_VIEW"] && strlen($arItem["CATALOG_PRICE_".$value["ID"]]) > 0)
{
// get final price with VAT included.
if ($arItem['CATALOG_VAT_INCLUDED'] != 'Y')
{
$arItem['CATALOG_PRICE_'.$value['ID']] *= (1 + $arItem['CATALOG_VAT'] * 0.01);
}
// so discounts will include VAT
$arDiscounts = CCatalogDiscount::GetDiscount(
$arItem["ID"],
$arItem["IBLOCK_ID"],
array($value["ID"]),
$arUserGroups,
"N",
$LID,
array()
);
$discountPrice = CCatalogProduct::CountPriceWithDiscount(
$arItem["CATALOG_PRICE_".$value["ID"]],
$arItem["CATALOG_CURRENCY_".$value["ID"]],
$arDiscounts
);
// get clear prices WO VAT
$arItem['CATALOG_PRICE_'.$value['ID']] /= (1 + $arItem['CATALOG_VAT'] * 0.01);
$discountPrice /= (1 + $arItem['CATALOG_VAT'] * 0.01);
$vat_value_discount = $discountPrice * $arItem['CATALOG_VAT'] * 0.01;
$vat_discountPrice = $discountPrice + $vat_value_discount;
$vat_value = $arItem['CATALOG_PRICE_'.$value['ID']] * $arItem['CATALOG_VAT'] * 0.01;
$vat_price = $arItem["CATALOG_PRICE_".$value["ID"]] + $vat_value;
if ($boolConvert && $strCurrencyID != $arItem["CATALOG_CURRENCY_".$value["ID"]])
{
$strOrigCurrencyID = $arItem["CATALOG_CURRENCY_".$value["ID"]];
$dblOrigNoVat = $arItem["CATALOG_PRICE_".$value["ID"]];
$dblNoVat = CCurrencyRates::ConvertCurrency($dblOrigNoVat, $strOrigCurrencyID, $strCurrencyID);
$dblVatPrice = CCurrencyRates::ConvertCurrency($vat_price, $strOrigCurrencyID, $strCurrencyID);
$dblVatValue = CCurrencyRates::ConvertCurrency($vat_value, $strOrigCurrencyID, $strCurrencyID);
$dblDiscountValueNoVat = CCurrencyRates::ConvertCurrency($discountPrice, $strOrigCurrencyID, $strCurrencyID);
$dblVatDiscountPrice = CCurrencyRates::ConvertCurrency($vat_discountPrice, $strOrigCurrencyID, $strCurrencyID);
$dblDiscountValueVat = CCurrencyRates::ConvertCurrency($vat_value_discount, $strOrigCurrencyID, $strCurrencyID);
$arPrices[$key] = array(
'ORIG_VALUE_NOVAT' => $dblOrigNoVat,
"VALUE_NOVAT" => $dblNoVat,
"PRINT_VALUE_NOVAT" => CCurrencyLang::CurrencyFormat($dblNoVat, $strCurrencyID, true),
'ORIG_VALUE_VAT' => $vat_price,
"VALUE_VAT" => $dblVatPrice,
"PRINT_VALUE_VAT" => CCurrencyLang::CurrencyFormat($dblVatPrice, $strCurrencyID, true),
//.........这里部分代码省略.........
示例5: GetDiscountByProduct
public function GetDiscountByProduct($productID = 0, $arUserGroups = array(), $renewal = "N", $arCatalogGroups = array(), $siteID = false, $arDiscountCoupons = false)
{
global $APPLICATION;
foreach (GetModuleEvents("catalog", "OnGetDiscountByProduct", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, array($productID, $arUserGroups, $renewal, $arCatalogGroups, $siteID, $arDiscountCoupons));
if (true !== $mxResult) {
return $mxResult;
}
}
$productID = (int) $productID;
if ($productID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND', array('#ID' => $productID)), 'NO_ELEMENT');
return false;
}
$intIBlockID = CIBlockElement::GetIBlockByID($productID);
if ($intIBlockID === false) {
$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_DISC_ERR_ELEMENT_ID_NOT_FOUND', array('#ID#' => $productID)), 'NO_ELEMENT');
return false;
}
return CCatalogDiscount::GetDiscount($productID, $intIBlockID, $arCatalogGroups, $arUserGroups, $renewal, $siteID, $arDiscountCoupons);
}
示例6: GetItemPrices
public static function GetItemPrices($IBLOCK_ID, $arCatalogPrices, $arItem, $bVATInclude = true, $arCurrencyParams = array(), $USER_ID = 0, $LID = SITE_ID)
{
static $arCurUserGroups = array();
global $USER;
$arPrices = array();
if(CModule::IncludeModule("catalog"))
{
$USER_ID = intval($USER_ID);
$intUserID = $USER_ID;
if (0 >= $intUserID)
$intUserID = $USER->GetID();
if (!array_key_exists($intUserID, $arCurUserGroups))
{
$arCurUserGroups[$intUserID] = (0 < $USER_ID ? CUser::GetUserGroup($USER_ID) : $USER->GetUserGroupArray());
}
$arUserGroups = $arCurUserGroups[$intUserID];
$boolConvert = false;
$strCurrencyID = '';
if (is_array($arCurrencyParams) && !empty($arCurrencyParams) && !empty($arCurrencyParams['CURRENCY_ID']))
{
$boolConvert = true;
$strCurrencyID = $arCurrencyParams['CURRENCY_ID'];
}
foreach($arCatalogPrices as $key => $value)
{
if($value["CAN_VIEW"] && strlen($arItem["CATALOG_PRICE_".$value["ID"]]) > 0)
{
// get final price with VAT included.
if ($arItem['CATALOG_VAT_INCLUDED'] != 'Y')
{
$arItem['CATALOG_PRICE_'.$value['ID']] *= (1 + $arItem['CATALOG_VAT'] * 0.01);
}
CCatalogDiscountSave::Disable();
// so discounts will include VAT
$arDiscounts = CCatalogDiscount::GetDiscount(
$arItem["ID"],
$arItem["IBLOCK_ID"],
array($value["ID"]),
$arUserGroups,
"N",
$LID,
array()
);
CCatalogDiscountSave::Enable();
$discountPrice = CCatalogProduct::CountPriceWithDiscount(
$arItem["CATALOG_PRICE_".$value["ID"]],
$arItem["CATALOG_CURRENCY_".$value["ID"]],
$arDiscounts
);
// get clear prices WO VAT
$arItem['CATALOG_PRICE_'.$value['ID']] /= (1 + $arItem['CATALOG_VAT'] * 0.01);
$discountPrice /= (1 + $arItem['CATALOG_VAT'] * 0.01);
$vat_value_discount = $discountPrice * $arItem['CATALOG_VAT'] * 0.01;
$vat_discountPrice = $discountPrice + $vat_value_discount;
$vat_value = $arItem['CATALOG_PRICE_'.$value['ID']] * $arItem['CATALOG_VAT'] * 0.01;
$vat_price = $arItem["CATALOG_PRICE_".$value["ID"]] + $vat_value;
if ($boolConvert && $strCurrencyID != $arItem["CATALOG_CURRENCY_".$value["ID"]])
{
$strOrigCurrencyID = $arItem["CATALOG_CURRENCY_".$value["ID"]];
$dblOrigNoVat = $arItem["CATALOG_PRICE_".$value["ID"]];
$dblNoVat = CCurrencyRates::ConvertCurrency($dblOrigNoVat, $strOrigCurrencyID, $strCurrencyID);
$dblVatPrice = CCurrencyRates::ConvertCurrency($vat_price, $strOrigCurrencyID, $strCurrencyID);
$dblVatValue = CCurrencyRates::ConvertCurrency($vat_value, $strOrigCurrencyID, $strCurrencyID);
$dblDiscountValueNoVat = CCurrencyRates::ConvertCurrency($discountPrice, $strOrigCurrencyID, $strCurrencyID);
$dblVatDiscountPrice = CCurrencyRates::ConvertCurrency($vat_discountPrice, $strOrigCurrencyID, $strCurrencyID);
$dblDiscountValueVat = CCurrencyRates::ConvertCurrency($vat_value_discount, $strOrigCurrencyID, $strCurrencyID);
$arPrices[$key] = array(
'ORIG_VALUE_NOVAT' => $dblOrigNoVat,
"VALUE_NOVAT" => $dblNoVat,
"PRINT_VALUE_NOVAT" => FormatCurrency($dblNoVat, $strCurrencyID),
'ORIG_VALUE_VAT' => $vat_price,
"VALUE_VAT" => $dblVatPrice,
"PRINT_VALUE_VAT" => FormatCurrency($dblVatPrice, $strCurrencyID),
'ORIG_VATRATE_VALUE' => $vat_value,
"VATRATE_VALUE" => $dblVatValue,
"PRINT_VATRATE_VALUE" => FormatCurrency($dblVatValue, $strCurrencyID),
'ORIG_DISCOUNT_VALUE_NOVAT' => $discountPrice,
"DISCOUNT_VALUE_NOVAT" => $dblDiscountValueNoVat,
"PRINT_DISCOUNT_VALUE_NOVAT" => FormatCurrency($dblDiscountValueNoVat, $strCurrencyID),
"ORIG_DISCOUNT_VALUE_VAT" => $vat_discountPrice,
"DISCOUNT_VALUE_VAT" => $dblVatDiscountPrice,
"PRINT_DISCOUNT_VALUE_VAT" => FormatCurrency($dblVatDiscountPrice, $strCurrencyID),
'ORIG_DISCOUNT_VATRATE_VALUE' => $vat_value_discount,
'DISCOUNT_VATRATE_VALUE' => $dblDiscountValueVat,
'PRINT_DISCOUNT_VATRATE_VALUE' => FormatCurrency($dblDiscountValueVat, $strCurrencyID),
'ORIG_CURRENCY' => $strOrigCurrencyID,
"CURRENCY" => $strCurrencyID,
);
//.........这里部分代码省略.........
示例7: GetOptimalPrice
//.........这里部分代码省略.........
$dbPriceList = CPrice::GetListEx(array(), array("PRODUCT_ID" => $intProductID, "GROUP_GROUP_ID" => $arUserGroups, "GROUP_BUY" => "Y", "+<=QUANTITY_FROM" => $quantity, "+>=QUANTITY_TO" => $quantity), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY"));
while ($arPriceList = $dbPriceList->Fetch()) {
$arPriceList['ELEMENT_IBLOCK_ID'] = $intIBlockID;
$arPrices[] = $arPriceList;
}
unset($arPriceList, $dbPriceList);
} else {
foreach ($arPrices as &$arOnePrice) {
$arOnePrice['ELEMENT_IBLOCK_ID'] = $intIBlockID;
}
unset($arOnePrice);
}
if (empty($arPrices)) {
return false;
}
$rsVAT = CCatalogProduct::GetVATInfo($intProductID);
if ($arVAT = $rsVAT->Fetch()) {
$arVAT['RATE'] = (double) $arVAT['RATE'] * 0.01;
} else {
$arVAT = array('RATE' => 0.0, 'VAT_INCLUDED' => 'N');
}
unset($rsVAT);
if (self::getUseDiscount()) {
if ($arDiscountCoupons === false) {
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
}
}
// $boolDiscountVat = ('N' != COption::GetOptionString('catalog', 'discount_vat', 'Y'));
$boolDiscountVat = true;
$minPrice = false;
$basePrice = false;
$arMinPrice = array();
$arMinDiscounts = array();
foreach ($arPrices as &$arPriceList) {
$arPriceList['VAT_RATE'] = $arVAT['RATE'];
$arPriceList['VAT_INCLUDED'] = $arVAT['VAT_INCLUDED'];
$dblCurrentPrice = $arPriceList['PRICE'];
if ($boolDiscountVat) {
if ('N' == $arPriceList['VAT_INCLUDED']) {
$dblCurrentPrice *= 1 + $arPriceList['VAT_RATE'];
}
} else {
if ('Y' == $arPriceList['VAT_INCLUDED']) {
$dblCurrentPrice /= 1 + $arPriceList['VAT_RATE'];
}
}
if ($arPriceList['CURRENCY'] != $resultCurrency) {
$dblCurrentPrice = CCurrencyRates::ConvertCurrency($arPriceList['PRICE'], $arPriceList['CURRENCY'], $resultCurrency);
}
$dblCurrentPrice = roundEx($dblCurrentPrice, CATALOG_VALUE_PRECISION);
$arDiscounts = array();
if (self::getUseDiscount()) {
$arDiscounts = CCatalogDiscount::GetDiscount($intProductID, $intIBlockID, $arPriceList["CATALOG_GROUP_ID"], $arUserGroups, $renewal, $siteID, $arDiscountCoupons);
}
$result = CCatalogDiscount::applyDiscountList($dblCurrentPrice, $resultCurrency, $arDiscounts);
if ($result === false) {
return false;
}
if ($minPrice === false || $minPrice > $result['PRICE']) {
$basePrice = $dblCurrentPrice;
$minPrice = $result['PRICE'];
$arMinPrice = $arPriceList;
$arMinDiscounts = $result['DISCOUNT_LIST'];
}
}
unset($arPriceList);
if ($boolDiscountVat) {
if (!self::$optimalPriceWithVat) {
$minPrice /= 1 + $arMinPrice['VAT_RATE'];
$basePrice /= 1 + $arMinPrice['VAT_RATE'];
$minPrice = roundEx($minPrice, CATALOG_VALUE_PRECISION);
$basePrice = roundEx($basePrice, CATALOG_VALUE_PRECISION);
}
} else {
if (self::$optimalPriceWithVat) {
$minPrice *= 1 + $arMinPrice['VAT_RATE'];
$basePrice *= 1 + $arMinPrice['VAT_RATE'];
$minPrice = roundEx($minPrice, CATALOG_VALUE_PRECISION);
$basePrice = roundEx($basePrice, CATALOG_VALUE_PRECISION);
}
}
$arResult = array('PRICE' => $arMinPrice, 'RESULT_PRICE' => array('BASE_PRICE' => $basePrice, 'DISCOUNT_PRICE' => $minPrice, 'DISCOUNT' => $basePrice - $minPrice, 'PERCENT' => $basePrice > 0 ? 100 * ($basePrice - $minPrice) / $basePrice : 0, 'CURRENCY' => $resultCurrency, 'VAT_RATE' => $arMinPrice['VAT_RATE'], 'VAT_INCLUDED' => self::$optimalPriceWithVat ? 'Y' : 'N'), 'DISCOUNT_PRICE' => $minPrice, 'DISCOUNT' => array(), 'DISCOUNT_LIST' => array());
if (!empty($arMinDiscounts)) {
reset($arMinDiscounts);
$arResult['DISCOUNT'] = current($arMinDiscounts);
$arResult['DISCOUNT_LIST'] = $arMinDiscounts;
}
if ($eventOnResultExists === true || $eventOnResultExists === null) {
foreach (GetModuleEvents('catalog', 'OnGetOptimalPriceResult', true) as $arEvent) {
$eventOnResultExists = true;
if (ExecuteModuleEventEx($arEvent, array(&$arResult)) === false) {
return false;
}
}
if ($eventOnResultExists === null) {
$eventOnResultExists = false;
}
}
return $arResult;
}
示例8: GetDiscount
static public function GetDiscount($intProductID, $intIBlockID, $arCatalogGroups = array(), $arUserGroups = array(), $strRenewal = "N", $siteID = false, $arDiscountCoupons = false, $boolSKU = true, $boolGetIDS = false)
{
global $DB;
global $APPLICATION;
global $stackCacheManager;
foreach (GetModuleEvents("catalog", "OnGetDiscount", true) as $arEvent)
{
$mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $intIBlockID, $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, $boolSKU, $boolGetIDS));
if (true !== $mxResult)
return $mxResult;
}
$boolSKU = (true === $boolSKU ? true : false);
$boolGetIDS = (true === $boolGetIDS ? true : false);
$intProductID = intval($intProductID);
if (0 >= $intProductID)
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$intIBlockID = intval($intIBlockID);
if (0 >= $intIBlockID)
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_IBLOCK_ID_ABSENT"), "NO_IBLOCK_ID");
return false;
}
if (!empty($arCatalogGroups))
{
if (!is_array($arCatalogGroups))
{
$arCatalogGroups = (intval($arCatalogGroups)."|" == $arCatalogGroups."|" ? array($arCatalogGroups) : array());
}
}
else
{
$arCatalogGroups = array();
}
if (!empty($arCatalogGroups))
{
CatalogClearArray($arCatalogGroups);
}
if (!is_array($arUserGroups))
{
$arUserGroups = (intval($arUserGroups)."|" == $arUserGroups."|" ? array($arUserGroups) : array());
}
$arUserGroups[] = 2;
if (!empty($arUserGroups))
{
CatalogClearArray($arUserGroups);
}
$strRenewal = (($strRenewal == "Y") ? "Y" : "N");
if ($siteID === false)
$siteID = SITE_ID;
if ($arDiscountCoupons === false)
$arDiscountCoupons = CCatalogDiscountCoupon::GetCoupons();
$arSKU = false;
$arResult = array();
$arResultID = array();
$strCacheKey = md5('C'.implode('_', $arCatalogGroups).'-'.'U'.implode('_', $arUserGroups));
if (!array_key_exists($strCacheKey, self::$arCacheDiscountFilter))
{
$arFilter = array(
'PRICE_TYPE_ID' => $arCatalogGroups,
'USER_GROUP_ID' => $arUserGroups,
);
$arDiscountIDs = CCatalogDiscount::__GetDiscountID($arFilter);
if (!empty($arDiscountIDs))
{
sort($arDiscountIDs);
}
self::$arCacheDiscountFilter[$strCacheKey] = $arDiscountIDs;
}
else
{
$arDiscountIDs = self::$arCacheDiscountFilter[$strCacheKey];
}
$arProduct = array();
if (!empty($arDiscountIDs))
{
$boolGenerate = false;
$strCacheKey = 'D'.implode('_', $arDiscountIDs).'-'.'S'.$siteID.'-R'.$strRenewal;
if (!empty($arDiscountCoupons))
{
$strCacheKey .= '-C'.implode('|', $arDiscountCoupons);
}
$strCacheKey = md5($strCacheKey);
//.........这里部分代码省略.........
示例9: TxtToHTML
<font class="smalltextblack"><?php
echo $arElement["PREVIEW_TEXT_TYPE"] == "html" ? $arElement["PREVIEW_TEXT"] : TxtToHTML($arElement["~PREVIEW_TEXT"]);
?>
</font>
<?php
}
?>
</td>
</tr>
<?php
if ($USE_PRICE_COUNT == "N") {
if (count($arPriceGroups) > 0 && count($arPriceGroups["view"]) > 0) {
foreach ($arCatalogGroups as $key => $value) {
if (in_array($key, $arPriceGroups["view"])) {
if (StrLen($arElement["CATALOG_PRICE_" . $key]) > 0) {
$arDiscounts = CCatalogDiscount::GetDiscount($arElement["ID"], $IBLOCK_ID, array($key), $GLOBALS["USER"]->GetUserGroupArray(), "N", SITE_ID, false);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arElement["CATALOG_PRICE_" . $key], $arElement["CATALOG_CURRENCY_" . $key], $arDiscounts);
?>
<tr>
<td colspan="3" style="padding-top:2px;"><font class="text"><?php
echo $value["NAME_LANG"];
?>
: <b><?php
if ($discountPrice < $arElement["CATALOG_PRICE_" . $key]) {
echo '<s>' . FormatCurrency($arElement["CATALOG_PRICE_" . $key], $arElement["CATALOG_CURRENCY_" . $key]) . '</s> <font color="red">' . FormatCurrency($discountPrice, $arElement["CATALOG_CURRENCY_" . $key]) . '</font>';
} else {
echo '<font color="red">' . FormatCurrency($arElement["CATALOG_PRICE_" . $key], $arElement["CATALOG_CURRENCY_" . $key]) . '</font>';
}
?>
</b></font></td>
</tr>