• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount/gift/manager.php
  • Класс: BitrixSaleDiscountGiftManager
  • Вызов: Manager::getCollectionsByProduct
public function getCollectionsByProduct(Basket $basket, array $product)
{
	$this->errorCollection->clear();

	if(!$this->existsDiscountsWithGift())
	{
		return array();
	}

	if(!$this->isValidProduct($product))
	{
		return null;
	}

	$pseudoBasket = $this->getBasketCopy($basket);
	$checkProductInBasket = $this->checkProductInBasket($product, $pseudoBasket);
	if($checkProductInBasket)
	{
		$this->deleteProductFromBasket($pseudoBasket, $product, false);
	}
	else
	{
		$this->addProductToBasket($pseudoBasket, $product);
	}

	$collectionsByPseudoBasket = $this->getCollectionsByBasket($pseudoBasket);
	$collectionsByBasket = $this->getCollectionsByBasket($basket);

	if(!$this->hasDifference($collectionsByBasket, $collectionsByPseudoBasket))
	{
		return array();
	}

	return $checkProductInBasket? $collectionsByBasket : $collectionsByPseudoBasket;
}