Setting up 1C-Bitrix coupons and promo codes

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

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.