Bitrix product subscription via API
Битрикс подписка на товар через API

All English-language materials have been translated fully automatically using the Google service

OEM component call code catalog.product.subscribe

<? $APPLICATION->IncludeComponent(
			'PRODUCT_ID' => $arItem['ID'],
			'BUTTON_ID' => $this->GetEditAreaId($arItem['ID']).'_subscribe',
			'BUTTON_CLASS' => 'btn btn-default product-item-detail-buy-button',
			'DEFAULT_DISPLAY' => !$actualItem['CAN_BUY'],
			'MESS_BTN_SUBSCRIBE' => 'Подписаться',
		array('HIDE_ICONS' => 'Y')

Subscription to a product in Bitrix

Adding a Product Subscription Using the API

$subscribeManager = new \Bitrix\Catalog\Product\SubscribeManager;
$contactTypes = $subscribeManager->contactTypes;

$subscribeData = array(
    'USER_CONTACT' => $USER->getEmail() ? $USER->getEmail() : false,
    'ITEM_ID' => 17715, //ID товара
    'SITE_ID' => 's1',
    'CONTACT_TYPE' => \Bitrix\Catalog\SubscribeTable::CONTACT_TYPE_EMAIL,
    'USER_ID' => $userId ? $userId : false,

$subscribeId = $subscribeManager->addSubscribe($subscribeData);


    $errorObject = current($subscribeManager->getErrors());
    $errors = array('error' => true);
        $errors['message'] = $errorObject->getMessage();
        if($errorObject->getCode() == $subscribeManager::ERROR_ADD_SUBSCRIBE_ALREADY_EXISTS)
            $errors['setButton'] = true;

The list of subscribers is in Store -> Buyers -> Subscribe to goods

Additional fields cannot be added to it.

Deleting a subscription to a product in Bitrix

$subscribeManager = new \Bitrix\Catalog\Product\SubscribeManager;
if(!$subscribeManager->deleteManySubscriptions($_POST['listSubscribeId'], $_POST['itemId']))
    $errorObject = current($subscribeManager->getErrors());
    if($errorObject) {
        $errors = $errorObject->getMessage();

Checking if the user is subscribed to the product

use Bitrix\Catalog\SubscribeTable;
use Bitrix\Catalog\Product\SubscribeManager;

global $USER;

foreach ($arResult['ITEMS'] as $k => &$item) {
	$userId = $USER->GetID();

	$filter = array(
		'ITEM_ID' => $item['ID'],
		'=SITE_ID' => SITE_ID,
			'LOGIC' => 'OR',
			array('=DATE_TO' => false),
			array('>DATE_TO' => date($DB->dateFormatToPHP(\CLang::getDateFormat('FULL')), time()))
	if ($userId)
		$filter['USER_ID'] = $userId;
			$filter['=Bitrix\Catalog\SubscribeAccessTable:SUBSCRIBE.TOKEN'] = $_SESSION['SUBSCRIBE_PRODUCT']['TOKEN'];
			$filter['=Bitrix\Catalog\SubscribeAccessTable:SUBSCRIBE.USER_CONTACT'] = $_SESSION['SUBSCRIBE_PRODUCT']['USER_CONTACT'];
			item['IS_SUBSCRIBED'] = false;

	$queryObject = SubscribeTable::getList(array('select' => array('ITEM_ID'), 'filter' => $filter));
	$subscribeManager = new SubscribeManager;
	$listRealItemId = array();
	while ($subscribe = $queryObject->fetch()) {
		$listRealItemId[] = $subscribe['ITEM_ID'];

	if (in_array($item['ID'], $listRealItemId))
		item['IS_SUBSCRIBED'] = true;
		item['IS_SUBSCRIBED'] = false;

Intercept the event responsible for sending the notification about the change in the status of the goods

AddEventHandler('main', 'OnBeforeEventAdd', array('OnBeforeEventAdd', 'OnProductNotify'));
class OnBeforeEventAdd {
   static function OnProductNotify(&$event, &$lid, &$arFields, &$message_id) {
        if ($event == 'CATALOG_PRODUCT_SUBSCRIBE_NOTIFY') {
			// Your logic is here

Bitrix settings for product receipt notifications

  // Module Trade Catalog
Enable quantitative accounting - yes
Allow purchase in the absence of goods - no
Allow negative quantity - no
Allow subscription if there is no product - yes

// Module Online store
Store settings -> Subscribe to goods -> Use notifications on goods receipt - yes  


Worth reading:


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96



Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number