Esempio n. 1
0
 /**
  * @param array $arParams
  * @return array|false
  */
 public static function OrderProduct($arParams)
 {
     $adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
     $arParams['RENEWAL'] = isset($arParams['RENEWAL']) && $arParams['RENEWAL'] == 'Y' ? 'Y' : 'N';
     $arParams['CHECK_QUANTITY'] = isset($arParams['CHECK_QUANTITY']) && $arParams['CHECK_QUANTITY'] == 'N' ? 'N' : 'Y';
     $arParams['CHECK_DISCOUNT'] = isset($arParams['CHECK_DISCOUNT']) && $arParams['CHECK_DISCOUNT'] == 'N' ? 'N' : 'Y';
     $arParams['USER_ID'] = isset($arParams['USER_ID']) ? (int) $arParams['USER_ID'] : 0;
     if ($arParams['USER_ID'] < 0) {
         $arParams['USER_ID'] = 0;
     }
     $arParams['SITE_ID'] = isset($arParams['SITE_ID']) ? $arParams['SITE_ID'] : false;
     $strSiteID = $arParams['SITE_ID'];
     $arParams['BASKET_ID'] = (string) (isset($arParams['BASKET_ID']) ? $arParams['BASKET_ID'] : '0');
     $arParams['CURRENCY'] = isset($arParams['CURRENCY']) ? Currency\CurrencyManager::checkCurrencyID($arParams['CURRENCY']) : false;
     if ($arParams['CURRENCY'] === false) {
         $arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);
     }
     global $USER;
     $productID = (int) $arParams['PRODUCT_ID'];
     $quantity = (double) $arParams['QUANTITY'];
     $intUserID = (int) $arParams['USER_ID'];
     $arResult = array();
     if ($adminSection) {
         if ($intUserID == 0) {
             return $arResult;
         }
         if (!($userGroups = static::getHitCache('USER_GROUPS', $intUserID))) {
             $userGroups = self::getUserGroups($intUserID);
             static::setHitCache('USER_GROUPS', $intUserID, $userGroups);
         }
         if (empty($userGroups)) {
             return $arResult;
         }
         if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT_PERM_N', $productID))) {
             $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productID, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSION' => 'N'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
             if ($arProduct = $dbIBlockElement->GetNext()) {
                 static::setHitCache('IBLOCK_ELEMENT_PERM_N', $productID, $arProduct);
             }
             unset($dbIBlockElement);
         }
         if (empty($arProduct) || !is_array($arProduct)) {
             return $arResult;
         }
         $iblockRightByID = null;
         if (!($iblockRightByID = static::getHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID']))) {
             if ($iblockRightByID = CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE')) {
                 static::setHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID'], $iblockRightByID);
             }
         }
         if ($iblockRightByID == 'E') {
             $proxyUserPermissionKey = $productID . "|" . $intUserID;
             if (!($arUserRights = static::getHitCache('USER_RIGHT', $proxyUserPermissionKey))) {
                 if ($arUserRights = CIBlockElementRights::GetUserOperations($productID, $intUserID)) {
                     static::setHitCache('USER_RIGHT', $proxyUserPermissionKey, $arUserRights);
                 }
             }
             if (empty($arUserRights) || !isset($arUserRights['element_read'])) {
                 return $arResult;
             }
             unset($arUserRights);
         } else {
             $proxyIblockPermissionKey = $arProduct['IBLOCK_ID'] . "|" . $intUserID;
             if (!($iblockPermissions = static::getHitCache('IBLOCK_PERM', $proxyIblockPermissionKey))) {
                 if ($iblockPermissions = CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID)) {
                     static::setHitCache('IBLOCK_PERM', $proxyIblockPermissionKey, $iblockPermissions);
                 }
             }
             if ($iblockPermissions < 'R') {
                 return $arResult;
             }
         }
     } else {
         $userGroups = $USER->GetUserGroupArray();
         if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT_PERM_Y', $productID))) {
             $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productID, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'R'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
             if ($arProduct = $dbIBlockElement->GetNext()) {
                 static::setHitCache('IBLOCK_ELEMENT_PERM_Y', $productID, $arProduct);
             }
             unset($dbIBlockElement);
         }
         if (empty($arProduct) || !is_array($arProduct)) {
             return $arResult;
         }
     }
     if (!($arCatalogProduct = static::getHitCache('CATALOG_PRODUCT', $productID))) {
         $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productID), false, false, array('ID', 'CAN_BUY_ZERO', 'QUANTITY_TRACE', 'QUANTITY', 'WEIGHT', 'WIDTH', 'HEIGHT', 'LENGTH', 'BARCODE_MULTI', 'TYPE'));
         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;
 }
Esempio n. 2
0
 /**
  * @deprecated deprecated since catalog 15.0.4
  * @see \Bitrix\Sale\DiscountCouponsManager
  */
 public static function CouponApply($intUserID, $strCoupon)
 {
     if (self::$existCouponsManager === null) {
         self::initCouponManager();
     }
     if (self::$existCouponsManager) {
         $couponList = is_array($strCoupon) ? $strCoupon : array($strCoupon);
         return DiscountCouponsManager::setApplyByProduct(array('MODULE' => 'catalog'), $couponList, true);
     } else {
         global $DB;
         $mxResult = false;
         $intUserID = (int) $intUserID;
         if ($intUserID < 0) {
             $intUserID = 0;
         }
         $arCouponList = array();
         $arCheck = is_array($strCoupon) ? $strCoupon : array($strCoupon);
         foreach ($arCheck as &$strOneCheck) {
             $strOneCheck = (string) $strOneCheck;
             if ('' != $strOneCheck) {
                 $arCouponList[] = $strOneCheck;
             }
         }
         if (isset($strOneCheck)) {
             unset($strOneCheck);
         }
         if (empty($arCouponList)) {
             return $mxResult;
         }
         $strDateFunction = $DB->GetNowFunction();
         $boolFlag = false;
         $couponIterator = Catalog\DiscountCouponTable::getList(array('select' => array('ID', 'TYPE', 'COUPON'), 'filter' => array('=COUPON' => $arCouponList, '=ACTIVE' => 'Y')));
         while ($arCoupon = $couponIterator->fetch()) {
             $arCoupon['ID'] = (int) $arCoupon['ID'];
             $arFields = array("~DATE_APPLY" => $strDateFunction);
             if ($arCoupon['TYPE'] == Catalog\DiscountCouponTable::TYPE_ONE_ROW) {
                 $arFields["ACTIVE"] = "N";
                 if (0 < $intUserID) {
                     CCatalogDiscountCoupon::EraseCouponByManage($intUserID, $arCoupon['COUPON']);
                 } else {
                     CCatalogDiscountCoupon::EraseCoupon($arCoupon['COUPON']);
                 }
             } elseif ($arCoupon['TYPE'] == Catalog\DiscountCouponTable::TYPE_ONE_ORDER) {
                 $boolFlag = true;
                 if (!isset(self::$arOneOrderCoupons[$arCoupon['ID']])) {
                     self::$arOneOrderCoupons[$arCoupon['ID']] = array('COUPON' => $arCoupon['COUPON'], 'USER_ID' => $intUserID);
                 }
             }
             $strUpdate = $DB->PrepareUpdate("b_catalog_discount_coupon", $arFields);
             if (!empty($strUpdate)) {
                 $strSql = "UPDATE b_catalog_discount_coupon SET " . $strUpdate . " WHERE ID = " . $arCoupon['ID'];
                 $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                 $mxResult = true;
             }
         }
         unset($arCoupon, $couponIterator);
         if ($boolFlag) {
             AddEventHandler('sale', 'OnBasketOrder', array('CCatalogDiscountCoupon', 'CouponOneOrderDisable'));
             AddEventHandler('sale', 'OnDoBasketOrder', array('CCatalogDiscountCoupon', 'CouponOneOrderDisable'));
         }
         return $mxResult;
     }
 }
 /**
  * Calculate basket discounts for save.
  *
  * @param array &$basket				Basket items.
  * @return bool
  */
 public static function calculateBasketDiscounts(&$basket)
 {
     if (!self::$init) {
         return false;
     }
     if (!self::isSuccess() || self::$useMode == self::MODE_SYSTEM || self::$useMode == self::MODE_DISABLED) {
         return false;
     }
     if (empty($basket) || !is_array($basket)) {
         return false;
     }
     Sale\DiscountCouponsManager::clearApply();
     if (self::$config['SALE_DISCOUNT_ONLY'] == 'Y' || empty(self::$basketDiscountList)) {
         return true;
     }
     $publicMode = self::usedByClient();
     foreach ($basket as $basketCode => $basketItem) {
         if (\CSaleBasketHelper::isSetItem($basketItem)) {
             continue;
         }
         $code = $publicMode ? $basketItem['ID'] : $basketCode;
         if (empty(self::$basketDiscountList[$code])) {
             continue;
         }
         $itemData = array('MODULE' => $basketItem['MODULE'], 'PRODUCT_ID' => $basketItem['PRODUCT_ID'], 'BASKET_ID' => $code);
         foreach (self::$basketDiscountList[$code] as $index => $discount) {
             $discountResult = self::convertDiscount($discount);
             if (!$discountResult->isSuccess()) {
                 return false;
             }
             $orderDiscountId = $discountResult->getId();
             $discountData = $discountResult->getData();
             $orderCouponId = '';
             self::$basketDiscountList[$code][$index]['ORDER_DISCOUNT_ID'] = $orderDiscountId;
             if ($discountData['USE_COUPONS'] == 'Y') {
                 if (empty($discount['COUPON'])) {
                     return false;
                 }
                 $couponResult = self::convertCoupon($discount['COUPON'], $orderDiscountId);
                 if (!$couponResult->isSuccess()) {
                     return false;
                 }
                 $orderCouponId = $couponResult->getId();
                 Sale\DiscountCouponsManager::setApplyByProduct($itemData, array($orderCouponId));
                 unset($couponResult);
             }
             unset($discountData, $discountResult);
             if (!isset(self::$discountResult['BASKET'][$code])) {
                 self::$discountResult['BASKET'][$code] = array();
             }
             self::$discountResult['BASKET'][$code][$index] = array('DISCOUNT_ID' => $orderDiscountId, 'COUPON_ID' => $orderCouponId, 'RESULT' => array('APPLY' => 'Y', 'DESCR' => false, 'DESCR_DATA' => false));
             $orderApplication = !empty(self::$discountsCache[$orderDiscountId]['APPLICATION']) ? self::$discountsCache[$orderDiscountId]['APPLICATION'] : null;
             if (!empty($orderApplication)) {
                 $basketItem['DISCOUNT_RESULT'] = !empty(self::$discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA']) ? self::$discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA'] : false;
                 $applyProduct = null;
                 eval('$applyProduct=' . $orderApplication . ';');
                 if (is_callable($applyProduct)) {
                     $applyProduct($basketItem);
                 }
                 unset($applyProduct);
                 if (!empty($basketItem['DISCOUNT_RESULT'])) {
                     self::$discountResult['BASKET'][$code][$index]['RESULT']['DESCR_DATA'] = $basketItem['DISCOUNT_RESULT']['BASKET'];
                     self::$discountResult['BASKET'][$code][$index]['RESULT']['DESCR'] = self::formatDescription($basketItem['DISCOUNT_RESULT']);
                 }
                 unset($basketItem['DISCOUNT_RESULT']);
             }
             unset($orderApplication);
         }
         unset($discount, $index);
     }
     unset($basketCode, $basketItem);
     return true;
 }
Esempio n. 4
0
 /**
  * Apply basket discount in new order.
  *
  * @return Result
  */
 protected function calculateFullBasketDiscount()
 {
     $result = new Result();
     if ((string) Main\Config\Option::get('sale', 'use_sale_discount_only') == 'Y') {
         return $result;
     }
     if (empty($this->basketDiscountList)) {
         return $result;
     }
     $applyExist = !empty($this->applyResult['DISCOUNT_LIST']) || !empty($this->applyResult['COUPON_LIST']) || !empty($this->applyResult['BASKET']);
     $basketCodeList = $this->getBasketCodes(true);
     foreach ($basketCodeList as &$basketCode) {
         if (empty($this->basketDiscountList[$basketCode])) {
             continue;
         }
         $itemData = array('MODULE' => $this->orderData['BASKET_ITEMS'][$basketCode]['MODULE'], 'PRODUCT_ID' => $this->orderData['BASKET_ITEMS'][$basketCode]['PRODUCT_ID'], 'BASKET_ID' => $basketCode);
         foreach ($this->basketDiscountList[$basketCode] as $index => $discount) {
             $discountResult = $this->convertDiscount($discount);
             if (!$discountResult->isSuccess()) {
                 $result->addErrors($discountResult->getErrors());
                 unset($discountResult);
                 return $result;
             }
             $orderDiscountId = $discountResult->getId();
             $discountData = $discountResult->getData();
             $orderCouponId = '';
             $this->basketDiscountList[$basketCode][$index]['ORDER_DISCOUNT_ID'] = $orderDiscountId;
             if ($discountData['USE_COUPONS'] == 'Y') {
                 if (empty($discount['COUPON'])) {
                     $result->addError(new Main\Entity\EntityError(Loc::getMessage('BX_SALE_DISCOUNT_ERR_DISCOUNT_WITHOUT_COUPON'), self::ERROR_ID));
                     return $result;
                 }
                 $couponResult = $this->convertCoupon($discount['COUPON'], $orderDiscountId);
                 if (!$couponResult->isSuccess()) {
                     $result->addErrors($couponResult->getErrors());
                     unset($couponResult);
                     return $result;
                 }
                 $orderCouponId = $couponResult->getId();
                 DiscountCouponsManager::setApplyByProduct($itemData, array($orderCouponId));
                 unset($couponResult);
             }
             unset($discountData, $discountResult);
             if (!isset($this->discountResult['BASKET'][$basketCode])) {
                 $this->discountResult['BASKET'][$basketCode] = array();
             }
             $this->discountResult['BASKET'][$basketCode][$index] = array('DISCOUNT_ID' => $orderDiscountId, 'COUPON_ID' => $orderCouponId, 'RESULT' => array('APPLY' => 'Y', 'DESCR' => false, 'DESCR_DATA' => false));
             $currentProduct = $this->orderData['BASKET_ITEMS'][$basketCode];
             $orderApplication = !empty($this->discountsCache[$orderDiscountId]['APPLICATION']) ? $this->discountsCache[$orderDiscountId]['APPLICATION'] : null;
             if (!empty($orderApplication)) {
                 $this->orderData['BASKET_ITEMS'][$basketCode]['DISCOUNT_RESULT'] = !empty($this->discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA']) ? $this->discountsCache[$orderDiscountId]['ACTIONS_DESCR_DATA'] : false;
                 $applyProduct = null;
                 eval('$applyProduct=' . $orderApplication . ';');
                 if (is_callable($applyProduct)) {
                     $applyProduct($this->orderData['BASKET_ITEMS'][$basketCode]);
                 }
                 unset($applyProduct);
                 if (!empty($this->orderData['BASKET_ITEMS'][$basketCode]['DISCOUNT_RESULT'])) {
                     $this->discountResult['BASKET'][$basketCode][$index]['RESULT']['DESCR_DATA'] = $this->orderData['BASKET_ITEMS'][$basketCode]['DISCOUNT_RESULT']['BASKET'];
                     $this->discountResult['BASKET'][$basketCode][$index]['RESULT']['DESCR'] = self::formatDescription($this->orderData['BASKET_ITEMS'][$basketCode]['DISCOUNT_RESULT']);
                 }
                 unset($this->orderData['BASKET_ITEMS'][$basketCode]['DISCOUNT_RESULT']);
             }
             unset($orderApplication);
             if ($applyExist) {
                 $disable = false;
                 if ($orderCouponId != '' && !empty($this->applyResult['COUPON_LIST'][$orderCouponId]) && $this->applyResult['COUPON_LIST'][$orderCouponId] == 'N') {
                     $disable = true;
                 } else {
                     if (!empty($this->applyResult['DISCOUNT_LIST'][$orderDiscountId]) && $this->applyResult['DISCOUNT_LIST'][$orderDiscountId] == 'N') {
                         $disable = true;
                     }
                     if (!empty($this->applyResult['BASKET'][$basketCode])) {
                         if (is_string($this->applyResult['BASKET'][$basketCode])) {
                             $disable = $this->applyResult['BASKET'][$basketCode] == 'N';
                         } elseif (!empty($this->applyResult['BASKET'][$basketCode][$orderDiscountId])) {
                             $disable = $this->applyResult['BASKET'][$basketCode][$orderDiscountId] == 'N';
                         }
                     }
                 }
                 if ($disable) {
                     $this->orderData['BASKET_ITEMS'][$basketCode] = $currentProduct;
                     $this->discountResult['BASKET'][$basketCode][$index]['RESULT']['APPLY'] = 'N';
                 }
             }
             unset($disable, $currentProduct);
         }
         unset($discount, $index);
     }
     unset($basketCode, $basketCodeList);
     return $result;
 }