\Bitrix\Main\EventManager::getInstance()->AddEventHandler("sale", "OnBasketAdd", "OnBeforePresentToBasket");
function OnBeforePresentToBasket($id, &$arFields) {
// Текущий сайт
$lid = \Bitrix\Main\Context::getCurrent()->getSite();
$fUser = Sale\Fuser::getId();
// Корзина пользователя
$basket = Sale\Basket::loadItemsForFUser(
$fUser,
$lid
);
$quantityList = $basket->getQuantityList();
if (count($quantityList) > 0) {
$basketItems = [];
foreach ($basket as $basketItem) {
$basketItems[] = intval($basketItem->getProductId());
}
if (!in_array(2243962, $basketItems)) {
Add2BasketByProductID(2243962);
}
}
}