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


PHP CCatalogDiscount::calculateDiscountList方法代码示例

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


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

示例1: OrderProduct


//.........这里部分代码省略.........
         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)) {
             $resultApply = DiscountCouponsManager::setApplyByProduct($productHash, $appliedCoupons);
         }
         unset($resultApply, $appliedCoupons);
     }
     if (empty($arPrice['PRICE']['CATALOG_GROUP_NAME'])) {
         if (!empty($arPrice['PRICE']['CATALOG_GROUP_ID'])) {
             $priceName = self::getPriceTitle($arPrice['PRICE']['CATALOG_GROUP_ID']);
             if ($priceName != '') {
                 $arPrice['PRICE']['CATALOG_GROUP_NAME'] = $priceName;
             }
             unset($priceName);
         }
     }
     if (empty($arPrice['RESULT_PRICE']) || !is_array($arPrice['RESULT_PRICE'])) {
         $arPrice['RESULT_PRICE'] = CCatalogDiscount::calculateDiscountList($arPrice['PRICE'], $arParams['CURRENCY'], $arDiscountList, true);
     }
     $arResult = array('PRODUCT_PRICE_ID' => $arPrice['PRICE']['ID'], 'BASE_PRICE' => $arPrice['RESULT_PRICE']['BASE_PRICE'], 'PRICE' => $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'], 'VAT_RATE' => $arPrice['PRICE']['VAT_RATE'], "CURRENCY" => $arPrice['RESULT_PRICE']['CURRENCY'], "WEIGHT" => (double) $arCatalogProduct["WEIGHT"], "DIMENSIONS" => serialize(array("WIDTH" => $arCatalogProduct["WIDTH"], "HEIGHT" => $arCatalogProduct["HEIGHT"], "LENGTH" => $arCatalogProduct["LENGTH"])), "NAME" => $arProduct["~NAME"], "CAN_BUY" => "Y", "DETAIL_PAGE_URL" => $arProduct['~DETAIL_PAGE_URL'], "NOTES" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "DISCOUNT_PRICE" => $arPrice['RESULT_PRICE']['DISCOUNT'], "TYPE" => $arCatalogProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : null, "DISCOUNT_VALUE" => $arPrice['RESULT_PRICE']['PERCENT'] > 0 ? $arPrice['RESULT_PRICE']['PERCENT'] . '%' : 0, "DISCOUNT_NAME" => '', "DISCOUNT_COUPON" => '', "DISCOUNT_LIST" => array());
     if ($arParams["CHECK_QUANTITY"] == "Y") {
         $arResult["QUANTITY"] = $quantity;
     } else {
         $arResult["QUANTITY"] = $arParams["QUANTITY"];
     }
     if (!empty($arDiscountList)) {
         $arResult['DISCOUNT_LIST'] = $arDiscountList;
     }
     if (!empty($arPrice['DISCOUNT'])) {
         $arResult['DISCOUNT_NAME'] = '[' . $arPrice['DISCOUNT']['ID'] . '] ' . $arPrice['DISCOUNT']['NAME'];
         if (!empty($arPrice['DISCOUNT']['COUPON'])) {
             $arResult['DISCOUNT_COUPON'] = $arPrice['DISCOUNT']['COUPON'];
         }
         if (empty($arResult['DISCOUNT_LIST'])) {
             $arResult['DISCOUNT_LIST'] = array($arPrice['DISCOUNT']);
         }
     }
     $arResult["VAT_INCLUDED"] = "Y";
     return $arResult;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:product_provider.php

示例2: updateUserHandlerOptimalPrice

 /**
  * Update result user handlers for event OnGetOptimalPrice.
  *
  * @param array &$userResult		Optimal price array.
  * @return void
  */
 public static function updateUserHandlerOptimalPrice(&$userResult)
 {
     global $APPLICATION;
     if (empty($userResult) || !is_array($userResult)) {
         $userResult = false;
         return;
     }
     if (empty($userResult['PRICE']) || !is_array($userResult['PRICE'])) {
         $userResult = false;
         return;
     }
     if (empty($userResult['RESULT_PRICE']) || !is_array($userResult['RESULT_PRICE'])) {
         $resultCurrency = CCurrency::GetBaseCurrency();
         if (empty($resultCurrency)) {
             $APPLICATION->ThrowException(Loc::getMessage('BT_MOD_CATALOG_PROD_ERR_NO_BASE_CURRENCY'), 'NO_BASE_CURRENCY');
             $userResult = false;
             return;
         }
         if (self::$usedCurrency !== null) {
             $resultCurrency = self::$usedCurrency;
         }
         $oldDiscountExist = !empty($userResult['DISCOUNT']) && is_array($userResult['DISCOUNT']);
         if ($oldDiscountExist) {
             if (empty($userResult['DISCOUNT']['MODULE_ID'])) {
                 $userResult['DISCOUNT']['MODULE_ID'] = 'catalog';
             }
             if ($userResult['DISCOUNT']['CURRENCY'] != $resultCurrency) {
                 Catalog\DiscountTable::convertCurrency($userResult['DISCOUNT'], $resultCurrency);
             }
         }
         if (!isset($userResult['DISCOUNT_LIST']) || !is_array($userResult['DISCOUNT_LIST'])) {
             $userResult['DISCOUNT_LIST'] = array();
             if ($oldDiscountExist) {
                 $userResult['DISCOUNT_LIST'][] = $userResult['DISCOUNT'];
             }
         }
         if (isset($userResult['DISCOUNT_LIST'])) {
             foreach ($userResult['DISCOUNT_LIST'] as &$discount) {
                 if (empty($discount['MODULE_ID'])) {
                     $discount['MODULE_ID'] = 'catalog';
                 }
                 if ($discount['CURRENCY'] != $resultCurrency) {
                     Catalog\DiscountTable::convertCurrency($discount, $resultCurrency);
                 }
             }
             unset($discount);
         }
         $userResult['RESULT_PRICE'] = CCatalogDiscount::calculateDiscountList($userResult['PRICE'], $resultCurrency, $userResult['DISCOUNT_LIST'], self::$optimalPriceWithVat);
     } else {
         $userResult['RESULT_PRICE']['BASE_PRICE'] = roundEx($userResult['RESULT_PRICE']['BASE_PRICE'], CATALOG_VALUE_PRECISION);
         $userResult['RESULT_PRICE']['DISCOUNT'] = roundEx($userResult['RESULT_PRICE']['DISCOUNT'], CATALOG_VALUE_PRECISION);
         $userResult['RESULT_PRICE']['DISCOUNT_PRICE'] = $userResult['RESULT_PRICE']['BASE_PRICE'] - $userResult['RESULT_PRICE']['DISCOUNT'];
         $userResult['RESULT_PRICE']['VAT_RATE'] = $userResult['PRICE']['VAT_RATE'];
     }
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:61,代码来源:product.php


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