/** * Process Puy Product. * * @param int $productID * @param float $quantity * @param array $values * @param array $arRewriteFields * @throws void|Bitrix\Main\SystemException */ protected function addProductToBasket($productID, $quantity, $values = array(), $arRewriteFields = array()) { $productProperties = array(); $productID = (int) $productID; $intProductIBlockID = (int) CIBlockElement::GetIBlockByID($productID); if ($intProductIBlockID > 0) { $productCatalogInfo = CCatalogSKU::getInfoByIblock($intProductIBlockID); $isOffer = CCatalogSKU::TYPE_OFFERS == $productCatalogInfo['CATALOG_TYPE']; if ($this->arParams['ADD_PROPERTIES_TO_BASKET'] == 'Y') { // Is not offer if (!$isOffer) { // Props not empty if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID])) { $productProperties = CIBlockPriceTools::CheckProductProperties($intProductIBlockID, $productID, $this->arParams['CART_PROPERTIES'][$intProductIBlockID], $values, $this->arParams['PARTIAL_PRODUCT_PROPERTIES'] == 'Y'); if (!is_array($productProperties)) { throw new SystemException(Loc::getMessage("CVP_PARTIAL_BASKET_PROPERTIES_ERROR")); } } } else { if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID])) { $productProperties = CIBlockPriceTools::GetOfferProperties($productID, $productCatalogInfo['PRODUCT_IBLOCK_ID'], $this->arParams['CART_PROPERTIES'][$intProductIBlockID]); } } } if (0 >= $quantity) { $rsRatios = CCatalogMeasureRatio::getList(array(), array('PRODUCT_ID' => $productID), false, false, array('PRODUCT_ID', 'RATIO')); if ($arRatio = $rsRatios->Fetch()) { $intRatio = (int) $arRatio['RATIO']; $dblRatio = (double) $arRatio['RATIO']; $quantity = $dblRatio > $intRatio ? $dblRatio : $intRatio; } } if (0 >= $quantity) { $quantity = 1; } } else { throw new SystemException(Loc::getMessage('CVP_CATALOG_PRODUCT_NOT_FOUND') . "."); } if (!Add2BasketByProductID($productID, $quantity, $arRewriteFields, $productProperties)) { throw new SystemException(Loc::getMessage("CVP_CATALOG_ERROR2BASKET") . "."); } }