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


PHP CCatalogDiscount::getDiscountHandlers方法代码示例

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


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

示例1: GetDiscount


//.........这里部分代码省略.........
     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();
                     }
                     $arDiscountCoupons = $_SESSION["CATALOG_USER_COUPONS"];
                 }
             }
             if ($arDiscountCoupons === false) {
                 $arDiscountCoupons = array();
             }
             $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])) {
                 $arDiscountList = array();
                 $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', 'CONDITIONS');
                 $strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
                 $discountRows = array_chunk($arDiscountIDs, 500);
                 foreach ($discountRows as &$row) {
                     $arFilter = array('@ID' => $row, 'SITE_ID' => $siteID, 'TYPE' => self::ENTITY_ID, 'RENEWAL' => $strRenewal, '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate);
开发者ID:rasuldev,项目名称:torino,代码行数:67,代码来源:discount.php

示例2: 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();
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:discount.php


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