本文整理汇总了PHP中CCatalogDiscount::__Unpack方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::__Unpack方法的具体用法?PHP CCatalogDiscount::__Unpack怎么用?PHP CCatalogDiscount::__Unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscount
的用法示例。
在下文中一共展示了CCatalogDiscount::__Unpack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckDiscount
public function CheckDiscount($arProduct, $arDiscount)
{
if (empty($arProduct) || !is_array($arProduct)) {
return false;
}
if (empty($arDiscount) || !is_array($arDiscount) || !isset($arDiscount['UNPACK'])) {
return false;
}
return CCatalogDiscount::__Unpack($arProduct, $arDiscount['UNPACK']);
}
示例2: GetDiscountForProduct
public function GetDiscountForProduct($arProduct, $arParams = false)
{
global $DB;
$arResult = array();
$arResultID = array();
if (is_array($arProduct) && !empty($arProduct)) {
if (!is_array($arParams)) {
$arParams = array();
}
if (!isset($arProduct['ID'])) {
$arProduct['ID'] = 0;
}
$arProduct['ID'] = intval($arProduct['ID']);
if (!isset($arProduct['IBLOCK_ID'])) {
$arProduct['IBLOCK_ID'] = 0;
}
$arProduct['IBLOCK_ID'] = intval($arProduct['IBLOCK_ID']);
if (0 >= $arProduct['IBLOCK_ID']) {
return $arResult;
}
$arFieldsParams = array();
if (isset($arParams['TIME_ZONE'])) {
$arFieldsParams['TIME_ZONE'] = $arParams['TIME_ZONE'];
}
if (isset($arParams['PRODUCT'])) {
$arFieldsParams['PRODUCT'] = $arParams['PRODUCT'];
}
$boolGenerate = false;
$arSelect = array("ID", "SITE_ID", "SORT", "NAME", "VALUE_TYPE", "VALUE", "CURRENCY", 'UNPACK');
if (isset($arParams['DISCOUNT_FIELDS']) && is_array($arParams['DISCOUNT_FIELDS']) && !empty($arParams['DISCOUNT_FIELDS'])) {
$arSelect = $arParams['DISCOUNT_FIELDS'];
}
if (!in_array('UNPACK', $arSelect)) {
$arSelect[] = 'UNPACK';
}
$strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
if (isset($arParams['CURRENT_DATE'])) {
$strDate = $arParams['CURRENT_DATE'];
}
$strRenewal = 'N';
if (isset($arParams['RENEWAL'])) {
$strRenewal = $arParams['RENEWAL'];
} else {
$rsCatalogs = CCatalog::GetList(array(), array('ID' => $arProduct['IBLOCK_ID']), false, false, array('ID', 'SUBSCRIPTION'));
if ($arCatalog = $rsCatalogs->Fetch()) {
$strRenewal = $arCatalog['SUBSCRIPTION'];
}
}
if ('Y' != $strRenewal) {
$strRenewal = 'N';
}
$arSiteList = array();
if (isset($arParams['SITE_ID'])) {
if (!is_array($arParams['SITE_ID'])) {
$arParams['SITE_ID'] = array($arParams['SITE_ID']);
}
if (!empty($arParams['SITE_ID'])) {
$arSiteList = $arParams['SITE_ID'];
}
}
if (empty($arSiteList)) {
$rsIBlockSites = CIBlock::GetSite($arProduct['IBLOCK_ID']);
while ($arIBlockSite = $rsIBlockSites->Fetch()) {
$arSiteList[] = $arIBlockSite['SITE_ID'];
}
}
$arFilter = array("SITE_ID" => $arSiteList, "TYPE" => DISCOUNT_TYPE_STANDART, "ACTIVE" => "Y", "RENEWAL" => $strRenewal, "+<=ACTIVE_FROM" => $strDate, "+>=ACTIVE_TO" => $strDate, 'COUPON' => '');
$rsPriceDiscounts = CCatalogDiscount::GetList(array(), $arFilter, false, false, $arSelect);
while ($arPriceDiscount = $rsPriceDiscounts->Fetch()) {
if ($arPriceDiscount['COUPON_ACTIVE'] != 'N') {
if (!$boolGenerate) {
if (!self::__GenerateFields($arProduct, $arFieldsParams)) {
return $arResult;
}
$boolGenerate = true;
}
if (CCatalogDiscount::__Unpack($arProduct, $arPriceDiscount['UNPACK'])) {
unset($arPriceDiscount['UNPACK']);
$arResult[] = $arPriceDiscount;
$arResultID[] = $arPriceDiscount['ID'];
}
}
}
if (isset($arParams['SKU']) && 'Y' == $arParams['SKU']) {
if (isset($arParams['SKU_PARAMS']) && is_array($arParams['SKU_PARAMS']) && !empty($arParams['SKU_PARAMS'])) {
$arSKU = $arParams['SKU_PARAMS'];
} else {
$arSKU = CCatalogSKU::GetInfoByOfferIBlock($arProduct['IBLOCK_ID']);
}
if (is_array($arSKU)) {
$arParent = array();
$arParent['ID'] = 0;
$arParent['IBLOCK_ID'] = $arSKU['PRODUCT_IBLOCK_ID'];
if (isset($arProduct['PROPERTY_' . $arSKU['SKU_PROPERTY_ID'] . '_VALUE']) && is_array($arProduct['PROPERTY_' . $arSKU['SKU_PROPERTY_ID'] . '_VALUE'])) {
$intParentID = intval(current($arProduct['PROPERTY_' . $arSKU['SKU_PROPERTY_ID'] . '_VALUE']));
if (0 < $intParentID) {
$arParent['ID'] = $intParentID;
}
}
$arParentParams = array();
//.........这里部分代码省略.........
示例3: CheckDiscount
static public function CheckDiscount($arProduct, $arDiscount)
{
if (empty($arProduct) || !is_array($arProduct))
return false;
if (empty($arDiscount) || !is_array(empty($arDiscount)) || !array_key_exists('UNPACK', $arDiscount))
return false;
return CCatalogDiscount::__Unpack($arProduct, $arDiscount['UNPACK']);
}