Age Restrictions for Product Categories in 1C-Bitrix
An online store launched a hunting goods section — and promptly received a letter from the regulatory authority. The issue was not the content itself but the absence of a category access restriction mechanism. Age restrictions at the category level are not merely a legal formality — they are an architectural task that 1C-Bitrix allows solving in several ways depending on business requirements.
Where Settings Live: Infoblock and Section Structure
In the Bitrix core, catalog categories are infoblock sections (b_iblock_section). The most convenient approach is to store the age restriction as a user-defined section property (UF field), rather than in a separate table. This makes it possible to manage restrictions directly in the admin panel without an additional interface.
Implementation scheme:
-
Create a UF field for the section via
Settings → User Fieldsor programmatically viaCUserTypeManager. Field type — list (enumeration) or integer. Example values:0,16,18,21. -
Link the restriction to child elements. When rendering the catalog, the
catalogcomponent callsCIBlockSection::GetList(). Here the logic is added: if a section has an age threshold set, check the user's session. -
Store the confirmed age in the session (
$_SESSION['AGE_CONFIRMED']or via Bitrix's\Bitrix\Main\Application::getInstance()->getSession()). After verification, the user does not go through the check again within the same session.
$sectionFields = CIBlockSection::GetByID($sectionId)->Fetch();
$ageLimit = (int)$sectionFields['UF_AGE_LIMIT'];
if ($ageLimit > 0) {
$session = \Bitrix\Main\Application::getInstance()->getSession();
$confirmedAge = (int)$session->get('USER_CONFIRMED_AGE');
if ($confirmedAge < $ageLimit) {
LocalRedirect('/age-confirm/?required=' . $ageLimit . '&back=' . urlencode($requestUri));
}
}
Cascading Restriction Inheritance
A tricky part — multi-level categories. If a parent section has an 18+ restriction, should child sections inherit it automatically? By default — no. Explicit logic is required.
Option 1: when a section is saved, an OnBeforeIBlockSectionAdd / OnBeforeIBlockSectionUpdate event handler recursively sets the UF field on child sections.
Option 2: during the check, traverse up the section chain (IBLOCK_SECTION_ID) and take the maximum restriction value from the entire branch. This option is more flexible — child sections can have their own, higher restrictions.
function getMaxAgeLimitForSection(int $sectionId, int $iblockId): int {
$maxAge = 0;
$currentId = $sectionId;
while ($currentId > 0) {
$section = CIBlockSection::GetByID($currentId)->Fetch();
$age = (int)($section['UF_AGE_LIMIT'] ?? 0);
$maxAge = max($maxAge, $age);
$currentId = (int)$section['IBLOCK_SECTION_ID'];
}
return $maxAge;
}
Catalog Display and Filtering
Products from restricted categories should not simply "break" — they must be correctly displayed or hidden depending on business requirements. Two approaches:
Hide entirely from results — via GetList with a filter on sections where UF_AGE_LIMIT <= the user's confirmed age. Works for search and the storefront simultaneously.
Show with a block — products are visible, but the "Buy" button is replaced with "Confirm Your Age". Implemented via the bitrix:catalog.element component template with a check of the section's UF field.
Category labels with restrictions (an "18+" badge) are added to the bitrix:catalog.section.list template — UF_AGE_LIMIT is taken from $arSection and the badge is conditionally rendered.
Admin Management
A new field will appear in the catalog section in the admin panel. The manager selects the restriction from a list when editing the section. Important: if the store uses D7 and components based on Bitrix\Iblock\Component\Base, the age check logic must be added to the OnBeforeComponentInit event handler or by overriding the getAdditionalFilter() method in the component class.
Delivery Timeframes
| Scope of Work | Timeframe |
|---|---|
| UF field + check for a single catalog | 4–8 hours |
| Cascading inheritance + search filtering | 1–2 days |
| Full system with sessions, redirects, and UI | 2–3 days |
Setting up age restrictions for categories is a task where details matter more than the overall scheme. A correctly implemented system does not slow down catalog loading and does not break SEO indexing of restricted products.

