本文整理汇总了PHP中CCatalogDiscountSave::GetDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscountSave::GetDiscount方法的具体用法?PHP CCatalogDiscountSave::GetDiscount怎么用?PHP CCatalogDiscountSave::GetDiscount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscountSave
的用法示例。
在下文中一共展示了CCatalogDiscountSave::GetDiscount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
//.........这里部分代码省略.........
示例2: GetDiscount
/**
* @param int $intProductID
* @param int $intIBlockID
* @param array $arCatalogGroups
* @param array $arUserGroups
* @param string $strRenewal
* @param bool|string $siteID
* @param bool|array $arDiscountCoupons
* @param bool $boolSKU
* @param bool $boolGetIDS
* @return array|false
*/
public function GetDiscount($intProductID, $intIBlockID, $arCatalogGroups = array(), $arUserGroups = array(), $strRenewal = "N", $siteID = false, $arDiscountCoupons = false, $boolSKU = true, $boolGetIDS = false)
{
static $eventOnGetExists = null;
static $eventOnResultExists = null;
global $DB, $APPLICATION;
self::initDiscountSettings();
if ($eventOnGetExists === true || $eventOnGetExists === null) {
foreach (GetModuleEvents("catalog", "OnGetDiscount", true) as $arEvent) {
$eventOnGetExists = true;
$mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $intIBlockID, $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, $boolSKU, $boolGetIDS));
if ($mxResult !== true) {
return $mxResult;
}
}
if ($eventOnGetExists === null) {
$eventOnGetExists = false;
}
}
$boolSKU = $boolSKU === true;
$boolGetIDS = $boolGetIDS === true;
$intProductID = (int) $intProductID;
if ($intProductID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_DISC_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$intIBlockID = (int) $intIBlockID;
if ($intIBlockID <= 0) {
$APPLICATION->ThrowException(Loc::getMessage("BT_MOD_CATALOG_DISC_ERR_IBLOCK_ID_ABSENT"), "NO_IBLOCK_ID");
return false;
}
if (!is_array($arUserGroups)) {
$arUserGroups = array($arUserGroups);
}
$arUserGroups[] = 2;
if (!empty($arUserGroups)) {
Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
}
if (!is_array($arCatalogGroups)) {
$arCatalogGroups = array($arCatalogGroups);
}
if (empty($arCatalogGroups)) {
$catalogGroupIterator = CCatalogGroup::GetGroupsList(array('GROUP_ID' => $arUserGroups, 'BUY' => array('Y', 'N')));
while ($catalogGroup = $catalogGroupIterator->Fetch()) {
$arCatalogGroups[$catalogGroup['CATALOG_GROUP_ID']] = $catalogGroup['CATALOG_GROUP_ID'];
}
unset($catalogGroup, $catalogGroupIterator);
}
if (!empty($arCatalogGroups)) {
Main\Type\Collection::normalizeArrayValuesByInt($arCatalogGroups, true);
}
if (empty($arCatalogGroups)) {
return false;
}
$strRenewal = (string) $strRenewal == 'Y' ? 'Y' : 'N';
if ($siteID === false) {
$siteID = SITE_ID;
}
$arSKUExt = false;
if ($boolSKU) {
$arSKUExt = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID);
$boolSKU = !empty($arSKUExt);
}
$arResult = array();
$arResultID = array();
if (self::$useSaleDiscount) {
} else {
$strCacheKey = md5('C' . implode('_', $arCatalogGroups) . '-' . 'U' . implode('_', $arUserGroups));
if (!isset(self::$arCacheDiscountFilter[$strCacheKey])) {
$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)) {
if ($arDiscountCoupons === false) {
if (self::$existCouponsManager && Loader::includeModule('sale')) {
$arDiscountCoupons = DiscountCouponsManager::getForApply(array('MODULE' => 'catalog', 'DISCOUNT_ID' => $arDiscountIDs), array('MODULE' => 'catalog', 'PRODUCT_ID' => $intProductID, 'BASKET_ID' => '0'), true);
if (!empty($arDiscountCoupons)) {
$arDiscountCoupons = array_keys($arDiscountCoupons);
}
} else {
if (!isset($_SESSION['CATALOG_USER_COUPONS']) || !is_array($_SESSION['CATALOG_USER_COUPONS'])) {
$_SESSION['CATALOG_USER_COUPONS'] = array();
//.........这里部分代码省略.........
示例3: intval
$arParams['USER_ID'] = intval($USER->GetID());
}
if (0 >= $arParams['USER_ID']) {
return;
}
$arParams['SHOW_NEXT_LEVEL'] = isset($arParams['SHOW_NEXT_LEVEL']) && 'Y' == $arParams['SHOW_NEXT_LEVEL'] ? 'Y' : 'N';
if (!CModule::IncludeModule('catalog')) {
return;
}
if (!CBXFeatures::IsFeatureEnabled('CatDiscountSave')) {
CCatalogDiscountSave::Disable();
ShowError(GetMessage("CAT_FEATURE_NOT_ALLOW"));
return;
}
$arFields = array('USER_ID' => $arParams['USER_ID'], 'SITE_ID' => $arParams['SITE_ID']);
$arResult = CCatalogDiscountSave::GetDiscount($arFields);
if (!empty($arResult)) {
foreach ($arResult as $key => $arDiscountSave) {
if ('Y' == $arParams['SHOW_NEXT_LEVEL']) {
$rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'ASC'), array('DISCOUNT_ID' => $arDiscountSave['ID'], '>RANGE_FROM' => $arDiscountSave['RANGE_FROM'], false, array('nTopCount' => 1)));
if ($arRange = $rsRanges->Fetch()) {
$arTempo = array('RANGE_FROM' => $arRange['RANGE_FROM'], 'VALUE' => $arRange['VALUE'], 'VALUE_TYPE' => $arRange['TYPE']);
$arDiscountSave['NEXT_LEVEL'] = $arTempo;
}
}
$arDiscountSave['~NAME'] = $arDiscountSave['NAME'];
$arDiscountSave['NAME'] = htmlspecialcharsex($arDiscountSave['NAME']);
$arResult[$key] = $arDiscountSave;
}
}
$this->IncludeComponentTemplate();
示例4: GetDiscount
public static function GetDiscount($intProductID, $intIBlockID, $arCatalogGroups = array(), $arUserGroups = array(), $strRenewal = "N", $siteID = false, $arDiscountCoupons = false, $boolSKU = true, $boolGetIDS = false)
{
global $DB;
global $APPLICATION;
foreach (GetModuleEvents("catalog", "OnGetDiscount", true) as $arEvent) {
$mxResult = ExecuteModuleEventEx($arEvent, array($intProductID, $intIBlockID, $arCatalogGroups, $arUserGroups, $strRenewal, $siteID, $arDiscountCoupons, $boolSKU, $boolGetIDS));
if ($mxResult !== true) {
return $mxResult;
}
}
$boolSKU = $boolSKU === true;
$boolGetIDS = $boolGetIDS === true;
$intProductID = (int) $intProductID;
if ($intProductID <= 0) {
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_PRODUCT_ID_ABSENT"), "NO_PRODUCT_ID");
return false;
}
$intIBlockID = (int) $intIBlockID;
if ($intIBlockID <= 0) {
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_IBLOCK_ID_ABSENT"), "NO_IBLOCK_ID");
return false;
}
if (!is_array($arCatalogGroups)) {
$arCatalogGroups = array($arCatalogGroups);
}
if (!empty($arCatalogGroups)) {
CatalogClearArray($arCatalogGroups);
}
if (!is_array($arUserGroups)) {
$arUserGroups = array($arUserGroups);
}
$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;
$arSKUExt = false;
if ($boolSKU) {
$arSKUExt = CCatalogSKU::GetInfoByOfferIBlock($intIBlockID);
$boolSKU = !empty($arSKUExt);
}
$arResult = array();
$arResultID = array();
$strCacheKey = md5('C' . implode('_', $arCatalogGroups) . '-' . 'U' . implode('_', $arUserGroups));
if (!isset(self::$arCacheDiscountFilter[$strCacheKey])) {
$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;
if (empty(self::$cacheDiscountHandlers)) {
self::$cacheDiscountHandlers = CCatalogDiscount::getDiscountHandlers($arDiscountIDs);
} else {
$needDiscountHandlers = array();
foreach ($arDiscountIDs as &$discountID) {
if (!isset(self::$cacheDiscountHandlers[$discountID])) {
$needDiscountHandlers[] = $discountID;
}
}
unset($discountID);
if (!empty($needDiscountHandlers)) {
$discountHandlersList = CCatalogDiscount::getDiscountHandlers($needDiscountHandlers);
if (!empty($discountHandlersList)) {
foreach ($discountHandlersList as $discountID => $discountHandlers) {
self::$cacheDiscountHandlers[$discountID] = $discountHandlers;
}
unset($discountHandlers, $discountID);
}
unset($discountHandlersList);
}
unset($needDiscountHandlers);
}
$strCacheKey = 'D' . implode('_', $arDiscountIDs) . '-' . 'S' . $siteID . '-R' . $strRenewal;
if (!empty($arDiscountCoupons)) {
$strCacheKey .= '-C' . implode('|', $arDiscountCoupons);
}
$strCacheKey = md5($strCacheKey);
if (!isset(self::$arCacheDiscountResult[$strCacheKey])) {
$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' => self::ENTITY_ID, 'RENEWAL' => $strRenewal, '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate);
if (is_array($arDiscountCoupons)) {
$arFilter["+COUPON"] = $arDiscountCoupons;
}
$arDiscountList = array();
CTimeZone::Disable();
//.........这里部分代码省略.........
示例5: 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);
//.........这里部分代码省略.........