示例#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;
 }
示例#2
0
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
    if (!\Bitrix\Main\Loader::includeModule("catalog")) {
        return array();
    }
    $arParams = array();
    static $proxyIblockElement = array();
    static $proxyCatalogMeasure = array();
    static $proxyParent = array();
    static $proxyIblockProperty = array();
    static $proxyProductData = array();
    static $proxyCatalogProduct = array();
    static $proxyCatalogMeasureRatio = array();
    $productId = (int) $productId;
    if ($productId <= 0) {
        return $arParams;
    }
    if (!empty($proxyIblockElement[$productId])) {
        $iblockId = $proxyIblockElement[$productId];
    } else {
        $iblockId = (int) CIBlockElement::GetIBlockByID($productId);
        if (intval($iblockId) > 0) {
            $proxyIblockElement[$productId] = $iblockId;
        }
    }
    if ($iblockId <= 0) {
        return $arParams;
    }
    $arSku2Parent = array();
    $arElementId = array();
    $arElementId[] = $productId;
    $proxyParentKey = $productId . "|" . $iblockId;
    if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey])) {
        $arParent = $proxyParent[$proxyParentKey];
    } else {
        $arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
        $proxyParent[$proxyParentKey] = $arParent;
    }
    if ($arParent) {
        $arElementId[] = $arParent["ID"];
        $arSku2Parent[$productId] = $arParent["ID"];
    }
    $arPropertyInfo = array();
    $userColumns = (string) $userColumns;
    $arUserColumns = $userColumns != '' ? explode(",", $userColumns) : array();
    foreach ($arUserColumns as $key => $column) {
        if (strncmp($column, 'PROPERTY_', 9) != 0) {
            unset($arUserColumns[$key]);
        } else {
            $column = strtoupper($column);
            $propertyCode = substr($column, 9);
            if ($propertyCode == '') {
                unset($arUserColumns[$key]);
                continue;
            }
            if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode])) {
                $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
            } else {
                $dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
                if ($arPropData = $dbres->GetNext()) {
                    $arPropertyInfo[$column] = $arPropData;
                    $proxyIblockProperty[$propertyCode] = $arPropData;
                }
            }
        }
    }
    $arSelect = array_merge(array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"), $arUserColumns);
    $proxyProductDataKey = md5(join('|', $arElementId) . "_" . join('|', $arSelect));
    if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey])) {
        $arProductData = $proxyProductData[$proxyProductDataKey];
    } else {
        $arProductData = getProductProps($arElementId, $arSelect);
        $proxyProductData[$proxyProductDataKey] = $arProductData;
    }
    $defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);
    if (!empty($arProductData)) {
        $arElementInfo = array();
        foreach ($arProductData as $elemId => &$arElement) {
            foreach ($arElement as $key => $value) {
                if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") {
                    $columnCode = str_replace("_VALUE", "", $key);
                    if (!isset($arPropertyInfo[$columnCode])) {
                        continue;
                    }
                    $keyResult = 'PROPERTY_' . $arPropertyInfo[$columnCode]['CODE'] . '_VALUE';
                    $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
                    if ($keyResult != $key) {
                        $arElement[$keyResult] = $arElement[$key];
                    }
                    unset($keyResult);
                }
            }
        }
        unset($arElement);
        if (isset($arProductData[$productId])) {
            $arElementInfo = $arProductData[$productId];
        }
        if (isset($arSku2Parent[$productId])) {
            $arParent = $arProductData[$arSku2Parent[$productId]];
        }
        if (!empty($arSku2Parent)) {
            foreach ($arUserColumns as $field) {
                $fieldVal = $field . "_VALUE";
                $parentId = $arSku2Parent[$productId];
                if ((!isset($arElementInfo[$fieldVal]) || isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
                    $arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
                }
            }
            if (strpos($arElementInfo["~XML_ID"], '#') === false) {
                $arElementInfo["~XML_ID"] = $arParent['~XML_ID'] . '#' . $arElementInfo["~XML_ID"];
            }
        }
        $arElementInfo["MODULE"] = "catalog";
        $arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
        $arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];
        if ($arElementInfo["IBLOCK_ID"] > 0) {
            $arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array("find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
        }
        $arBuyerGroups = CUser::GetUserGroup($userId);
        // price
        $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
        $currentUseDiscount = CCatalogProduct::getUseDiscount();
        CCatalogProduct::setUseDiscount(true);
        CCatalogProduct::setPriceVatIncludeMode(true);
        CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
        $arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
        CCatalogProduct::clearUsedCurrency();
        CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
        CCatalogProduct::setUseDiscount($currentUseDiscount);
        unset($currentUseDiscount, $currentVatMode);
        $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
        $arElementInfo['PRICE'] = $currentPrice;
        $arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
        $arElementInfo['DISCOUNT_PRICE'] = $arPrice['RESULT_PRICE']['DISCOUNT'];
        $currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE'];
        $discountPercent = (int) $arPrice['RESULT_PRICE']['PERCENT'];
        $arProduct = array();
        if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId])) {
            $arProduct = $proxyCatalogProduct[$productId];
        } else {
            $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI'));
            if ($arProduct = $rsProducts->Fetch()) {
                $proxyCatalogProduct[$productId] = $arProduct;
            }
        }
        if (empty($arProduct) || !is_array($arProduct)) {
            return array();
        }
        $balance = floatval($arProduct["QUANTITY"]);
        // sku props
        $arSkuData = array();
        $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $arElementInfo['~IBLOCK_XML_ID']);
        static $proxySkuProperty = array();
        if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId])) {
            $arSkuProperty = $proxySkuProperty[$productId];
        } else {
            $arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
            $proxySkuProperty[$productId] = $arSkuProperty;
        }
        if (!empty($arSkuProperty)) {
            foreach ($arSkuProperty as &$val) {
                $arSkuData[] = array('NAME' => $val['NAME'], 'VALUE' => $val['VALUE'], 'CODE' => $val['CODE']);
            }
            unset($val);
        }
        $arSkuData[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arElementInfo["~XML_ID"]);
        // currency
        $arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
        $priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);
        $arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];
        // measure
        $arElementInfo["MEASURE_TEXT"] = "";
        $arElementInfo["MEASURE_CODE"] = 0;
        if ((int) $arProduct["MEASURE"] > 0) {
            if (!empty($proxyCatalogMeasure[$arProduct["MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct["MEASURE"]])) {
                $arMeasure = $proxyCatalogMeasure[$arProduct["MEASURE"]];
            } else {
                $dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
                if ($arMeasure = $dbMeasure->Fetch()) {
                    $proxyCatalogMeasure[$arProduct["MEASURE"]] = $arMeasure;
                }
            }
            if (!empty($arMeasure) && is_array($arMeasure)) {
                $arElementInfo["MEASURE_TEXT"] = $arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"];
                $arElementInfo["MEASURE_CODE"] = $arMeasure["CODE"];
            }
        }
        if ($arElementInfo["MEASURE_TEXT"] == '') {
            $arElementInfo["MEASURE_TEXT"] = $defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"];
        }
        // ratio
        $arElementInfo["RATIO"] = 1;
        if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId])) {
            $arRatio = $proxyCatalogMeasureRatio[$productId];
        } else {
            $dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
            if ($arRatio = $dbratio->Fetch()) {
                $proxyCatalogMeasureRatio[$productId] = $arRatio;
            }
        }
        if (!empty($arRatio) && is_array($arRatio)) {
            $arElementInfo["RATIO"] = $arRatio["RATIO"];
        }
        // image
        $imgCode = '';
        $imgUrl = '';
        if ($arElementInfo["PREVIEW_PICTURE"] > 0) {
            $imgCode = $arElementInfo["PREVIEW_PICTURE"];
        } elseif ($arElementInfo["DETAIL_PICTURE"] > 0) {
            $imgCode = $arElementInfo["DETAIL_PICTURE"];
        }
        if ($imgCode == "" && count($arParent) > 0) {
            if ($arParent["PREVIEW_PICTURE"] > 0) {
                $imgCode = $arParent["PREVIEW_PICTURE"];
            } elseif ($arParent["DETAIL_PICTURE"] > 0) {
                $imgCode = $arParent["DETAIL_PICTURE"];
            }
        }
        if ($imgCode > 0) {
            $arFile = CFile::GetFileArray($imgCode);
            $arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
            if (is_array($arImgProduct)) {
                $imgUrl = $arImgProduct["src"];
            }
        }
        $arSetInfo = array();
        $arStores = array();
        /** @var $productProvider IBXSaleProductProvider */
        if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"]))) {
            // get set items if it is set
            if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET) {
                if (method_exists($productProvider, "GetSetItems")) {
                    $arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);
                    if ($tmpId == "") {
                        $tmpId = randString(7);
                    }
                    if (!empty($arSets)) {
                        foreach ($arSets as $arSetData) {
                            foreach ($arSetData["ITEMS"] as $setItem) {
                                $arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId);
                                // recursive call
                                // re-define some fields with set data values
                                $arSetItemParams["id"] = $setItem["PRODUCT_ID"];
                                $arSetItemParams["name"] = $setItem["NAME"];
                                $arSetItemParams["module"] = $setItem["MODULE"];
                                $arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
                                $arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
                                $arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
                                $arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
                                $arSetItemParams["productType"] = $setItem["TYPE"];
                                $arSetItemParams["weight"] = $setItem["WEIGHT"];
                                $arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
                                $arSetItemParams["setItems"] = "";
                                $arSetItemParams["setParentId"] = $productId . "_tmp" . $tmpId;
                                $arSetItemParams["isSetItem"] = "Y";
                                $arSetItemParams["isSetParent"] = "N";
                                $arSetInfo[] = $arSetItemParams;
                            }
                        }
                    }
                }
            }
            // get stores
            $storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID));
            // with exact SITE_ID or SITE_ID = NULL
            if ($storeCount > 0) {
                if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID))) {
                    $arStores = $arProductStore;
                }
            }
        }
        $currentTotalPrice = (double) $currentTotalPrice;
        // params array
        $arParams["id"] = $productId;
        $arParams["name"] = $arElementInfo["~NAME"];
        $arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
        $arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
        $arParams["urlImg"] = $imgUrl;
        $arParams["price"] = floatval($arElementInfo["PRICE"]);
        $arParams["priceBase"] = $currentTotalPrice;
        $arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
        $arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
        $arParams["valutaFormat"] = $priceValutaFormat;
        $arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
        $arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
        $arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
        $arParams["discountPercent"] = $discountPercent;
        $arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
        $arParams["quantity"] = $quantity;
        $arParams["module"] = $arElementInfo["MODULE"];
        $arParams["currency"] = $arElementInfo["CURRENCY"];
        $arParams["weight"] = $arElementInfo["WEIGHT"];
        $arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
        $arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
        $arParams["balance"] = $balance;
        $arParams["notes"] = !empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
        $arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
        $arParams["productXmlID"] = $arElementInfo["~XML_ID"];
        $arParams["callback"] = "";
        $arParams["orderCallback"] = "";
        $arParams["cancelCallback"] = "";
        $arParams["payCallback"] = "";
        $arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
        $arParams["skuProps"] = $arSkuData;
        $arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
        $arParams["measureCode"] = $arElementInfo["MEASURE_CODE"];
        $arParams["ratio"] = $arElementInfo["RATIO"];
        $arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];
        $arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
        $arParams["setParentId"] = empty($arSetInfo) ? "" : $productId . "_tmp" . $tmpId;
        $arParams["setItems"] = $arSetInfo;
        $arParams["isSetItem"] = "N";
        $arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";
        $arParams["stores"] = empty($arSetInfo) ? $arStores : array();
        $arParams["productPropsValues"] = $arElementInfo;
        // along with other information also contains values of properties with correct keys (after getProductProps)
    }
    return $arParams;
}
示例#3
0
 /**
  * Returns list of recommended products for specific product.
  *
  * @param int $USER_ID							User id.
  * @param string $LID							Site id.
  * @param array $arFilterRecomendet				Recomendation filter.
  * @param string $recomMore						Get more.
  * @param int $cntProductDefault				Max count.
  * @return array
  */
 function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
         $arRecomendet = array();
         if (!is_array($arFilterRecomendet)) {
             $arFilterRecomendet = array($arFilterRecomendet);
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
         if (empty($arFilterRecomendet)) {
             return $arRecomendetResult;
         }
         $iblockRecommended = array();
         $productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
         while ($product = $productIterator->fetch()) {
             $product['ID'] = (int) $product['ID'];
             $product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
             if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
                 $iblockRecommended[$product['IBLOCK_ID']] = array();
             }
             $iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
         }
         unset($product, $productIterator);
         if (empty($iblockRecommended)) {
             return $arRecomendetResult;
         }
         $propertyList = array();
         $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
             $propertyList[$property['IBLOCK_ID']] = $property['ID'];
         }
         unset($property, $propertyIterator);
         if (empty($propertyList)) {
             return $arRecomendetResult;
         }
         foreach ($propertyList as $iblockID => $propertyID) {
             $propertyValue = 'PROPERTY_' . $propertyID;
             $filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
             $select = array('ID', 'IBLOCK_ID', $propertyValue);
             $propertyValue .= '_VALUE';
             $elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
             while ($element = $elementIterator->Fetch()) {
                 if (empty($element[$propertyValue])) {
                     continue;
                 }
                 if (is_array($element[$propertyValue])) {
                     foreach ($element[$propertyValue] as &$recId) {
                         $recId = (int) $recId;
                         if ($recId > 0) {
                             $arRecomendet[$recId] = true;
                         }
                     }
                     unset($recId);
                 } else {
                     $recId = (int) $element[$propertyValue];
                     if ($recId > 0) {
                         $arRecomendet[$recId] = true;
                     }
                 }
             }
         }
         unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
         if (!empty($arRecomendet)) {
             $arRecomendet = array_keys($arRecomendet);
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
             $currentUseDiscount = CCatalogProduct::getUseDiscount();
             CCatalogProduct::setUseDiscount(true);
             CCatalogProduct::setPriceVatIncludeMode(true);
             CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
             $i = 0;
             while ($arElement = $rsElement->GetNext()) {
                 if (in_array($arElement["ID"], $arFilterRecomendet)) {
                     continue;
                 }
                 if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                     $arElement["MODULE"] = "catalog";
                     $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                     $arElement["PRODUCT_ID"] = $arElement["ID"];
                     $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
                     $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
                     $arElement["PRICE"] = $currentPrice;
                     $arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
                     $arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
                     if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                         $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
                     }
                     $arRecomendetResult[] = $arElement;
                     $i++;
                 }
             }
             CCatalogProduct::clearUsedCurrency();
             CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
             CCatalogProduct::setUseDiscount($currentUseDiscount);
             unset($currentUseDiscount, $currentVatMode);
         }
     }
     return $arRecomendetResult;
 }
	/**
	 * @param array $arParams
	 * @return array|false
	 */
	public static function OrderProduct($arParams)
	{
		$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');

		if (isset($arParams['CURRENCY']))
			$arParams['CURRENCY'] = CCurrency::checkCurrencyID($arParams['CURRENCY']);
		if ($arParams['CURRENCY'] === false)
			$arParams['CURRENCY'] = CSaleLang::GetLangCurrency($strSiteID ? $strSiteID : SITE_ID);

		global $USER;

		$productID = (int)$arParams['PRODUCT_ID'];
		$quantity = (float)$arParams['QUANTITY'];
		$renewal = $arParams['RENEWAL'];

		$intUserID = (int)$arParams['USER_ID'];

		$arResult = array();

		static $arUserCache = array();
		if (0 < $intUserID)
		{
			if (!isset($arUserCache[$intUserID]))
			{
				$by = 'ID';
				$order = 'DESC';
				$rsUsers = CUser::GetList($by, $order, array("ID_EQUAL_EXACT"=>$intUserID),array('FIELDS' => array('ID')));
				if ($arUser = $rsUsers->Fetch())
				{
					$arUser['ID'] = intval($arUser['ID']);
					$arUserCache[$arUser['ID']] = CUser::GetUserGroup($arUser['ID']);
				}
				else
				{
					$intUserID = 0;
					return $arResult;
				}
			}

			$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()))
				return $arResult;

			if ('E' == CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], "RIGHTS_MODE"))
			{
				$arUserRights = CIBlockElementRights::GetUserOperations($productID,$intUserID);
				if (empty($arUserRights))
				{
					return $arResult;
				}
				elseif (!is_array($arUserRights) || !array_key_exists('element_read',$arUserRights))
				{
					return $arResult;
				}
			}
			else
			{
				if ('R' > CIBlock::GetPermission($arProduct['IBLOCK_ID'], $intUserID))
				{
					return $arResult;
				}
			}
		}
		else
		{
			$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()))
				return $arResult;
		}

		$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())
		{
			$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 (0 < $intUserID)
		{
			$arCoupons = CCatalogDiscountCoupon::GetCouponsByManage($intUserID);
			CCatalogDiscountSave::SetDiscountUserID($intUserID);
		}
		else
		{
			$arCoupons = CCatalogDiscountCoupon::GetCoupons();
		}

		$userGroups = ($intUserID > 0 ? $arUserCache[$intUserID] : $USER->GetUserGroupArray());
		$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, $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);

		if (empty($arPrice))
		{
			if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, $quantity, $userGroups))
			{
				$quantity = $nearestQuantity;
				$arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $userGroups, $renewal, array(), (0 < $intUserID ? $strSiteID : false), $arCoupons);
			}
		}
		CCatalogProduct::clearUsedCurrency();
		CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
		CCatalogProduct::setUseDiscount($currentUseDiscount);
		unset($userGroups, $currentUseDiscount, $currentVatMode);
		if (0 < $intUserID)
		{
			CCatalogDiscountSave::ClearDiscountUserID();
		}

		if (empty($arPrice))
		{
			return $arResult;
		}

		$arDiscountList = array();
		$arCouponList = array();

		if (!empty($arPrice["DISCOUNT_LIST"]))
		{
			foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount)
			{
				$arOneList = array(
					'ID' => $arOneDiscount['ID'],
					'NAME' => $arOneDiscount['NAME'],
					'COUPON' => '',
					'COUPON_TYPE' => '',
					'MODULE_ID' => (isset($oneDiscount['MODULE_ID']) ? $oneDiscount['MODULE_ID'] : 'catalog'),
					'TYPE' => $arOneDiscount['TYPE'],
					'VALUE' => $arOneDiscount['VALUE'],
					'VALUE_TYPE' => $arOneDiscount['VALUE_TYPE'],
					'CURRENCY' => $arOneDiscount['CURRENCY'],
					'HANDLERS' => (isset($arOneDiscount['HANDLERS']) ? $arOneDiscount['HANDLERS'] : array())
				);

				if ($arOneDiscount['COUPON'])
				{
					$arOneList['COUPON'] = $arOneDiscount['COUPON'];
					$arOneList['COUPON_TYPE'] = $arOneDiscount['COUPON_ONE_TIME'];
					$arCouponList[] = $arOneDiscount['COUPON'];
				}

				$arDiscountList[] = $arOneList;
			}
			unset($arOneList, $arOneDiscount);
		}

		if (empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]))
		{
			if (!empty($arPrice["PRICE"]["CATALOG_GROUP_ID"]))
			{
				$rsCatGroups = CCatalogGroup::GetListEx(array(),array('ID' => $arPrice["PRICE"]["CATALOG_GROUP_ID"]),false,false,array('ID','NAME','NAME_LANG'));
				if ($arCatGroup = $rsCatGroups->Fetch())
				{
					$arPrice["PRICE"]["CATALOG_GROUP_NAME"] = (!empty($arCatGroup['NAME_LANG']) ? $arCatGroup['NAME_LANG'] : $arCatGroup['NAME']);
				}
			}
		}

		$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" => (float)$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($arPrice["DISCOUNT_LIST"]))
		{
			$arResult['DISCOUNT_LIST'] = $arDiscountList;
			$arResult["DISCOUNT_NAME"] = "[".$arPrice["DISCOUNT"]["ID"]."] ".$arPrice["DISCOUNT"]["NAME"];

			if (!empty($arPrice["DISCOUNT"]["COUPON"]))
			{
				$arResult["DISCOUNT_COUPON"] = $arPrice["DISCOUNT"]["COUPON"];
			}

			if (!empty($arCouponList))
			{
				$mxApply = CCatalogDiscountCoupon::CouponApply($intUserID, $arCouponList);
			}
		}

		return $arResult;
	}