Configuring Coupons and Promo Codes in 1C-Bitrix
Coupons in Bitrix are codes that, when entered, activate an associated marketing rule. A coupon doesn't work on its own: it's always linked to a discount rule in b_sale_discount. Coupon management: Store → Marketing → Coupons.
Types of coupons
| Type | Description | Table |
|---|---|---|
| General (reusable) | One code, multiple users, unlimited applications | b_sale_discount_coupon, TYPE = 1 |
| Unique single-use | One code — one use for everyone | TYPE = 2 |
| Unique per user | One code — one use per specific user | TYPE = 3 |
Creating a coupon through the interface
Store → Marketing → Discounts and promotions → [select rule] → Coupons → Add:
- Coupon code — entered manually or generated automatically
- Type — from the table above
- Activation/deactivation date — optional
- Maximum uses — for limited promotions
For bulk generation of unique coupons (for example, 1000 codes for email campaign) use the built-in generator in the coupons section or programmatic generation via \Bitrix\Sale\DiscountCouponsManager.
Programmatic coupon generation
$coupon = \Bitrix\Sale\DiscountCouponsManager::generateCoupon(true); // true = unique
\Bitrix\Sale\Internals\DiscountCouponTable::add([
'DISCOUNT_ID' => $discountId,
'ACTIVE' => 'Y',
'COUPON' => $coupon,
'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONCE,
'MAX_USE' => 1,
]);
Applying coupon in basket
Coupon is entered through a form in the basket. The standard component bitrix:sale.basket.basket contains a coupon input field. When "Apply" is clicked, \Bitrix\Sale\DiscountCouponsManager::add($coupon) is called, which validates the code and activates the associated rule.
Multiple coupons can be applied simultaneously if not prohibited by rule settings. The "Stop processing" flag (LAST_DISCOUNT = Y) in a rule blocks applying other discounts after this coupon.
Tracking usage
Used coupons are recorded in b_sale_discount_coupon (USE_COUNT, DATE_LAST_USE). For analytics: how many times a coupon was applied, for which orders, at what amount — this data can be obtained by joining b_sale_discount_coupon and b_sale_order_discount.
Estimated timeframes
Setting up a coupon system with one discount type and input field in basket — 3–5 hours. Bulk generation + mailing integration — 1 business day.







