Setting Up Promo Codes in 1C-Bitrix: Types, Generation, Debugging

We have seen many times how a promo code campaign fails due to an incorrect `LAST_DISCOUNT` flag. For example, on one project, a client sent out 50,000 unique coupons, but 80% did not work because the discount rule had `LAST_DISCOUNT = Y` set. After fixing it and regenerating the coupons, conversion

Our competencies:

Frequently Asked Questions

We have seen many times how a promo code campaign fails due to an incorrect LAST_DISCOUNT flag. For example, on one project, a client sent out 50,000 unique coupons, but 80% did not work because the discount rule had LAST_DISCOUNT = Y set. After fixing it and regenerating the coupons, conversion increased by 15%, and the number of orders with coupons grew by 25%. Let's break down how to set up coupons in 1C-Bitrix to avoid such errors. We'll cover types, mass generation, typical problems, and the implementation process.

Problems We Solve

Clients often face issues where coupons do not apply or give the wrong discount. The cause is incorrect configuration of marketing rules. If a rule has the 'Stop processing' flag set, once this coupon is applied, all other discounts (including other coupons) are blocked. Another problem is mass distribution of unique codes: manually creating thousands of coupons is impossible, and an incorrect script can create duplicates or reset limits. As a result, a company can lose up to 40% of potential campaign revenue.

How We Do It

We take a systematic approach. First, we analyze the marketing scenario: are multi-use codes needed? Personal discounts? Limits on amount or products? Then we design rules and coupons, considering compatibility with other promotions. We use native Bitrix mechanisms — information blocks, high-load blocks, ORM.

For mass generation, we write a PHP agent that creates tens of thousands of coupons in seconds. Comparison of manual vs programmatic generation:

Generation Method Time for 10,000 Coupons Error Risk Flexibility
Manual creation in admin panel ~several hours high (duplicates, typos) low
Programmatic agent (PHP) <0.5 seconds low (automatic validation) high (type, limits, binding)

Programmatic generation is 1000 times faster than manual and eliminates human error. The cost of developing the agent pays off in 2 months through automation.

According to 1C-Bitrix documentation, coupons can be of three types: general, unique one-time, and unique per user.

How to Generate Thousands of Unique Coupons in Seconds?

The built-in generator in the 'Shop → Marketing → Coupons' section allows creating up to 500 coupons at once. If you need more, we use a programmatic method. An agent launched via cron creates 10,000 coupons in 0.5 seconds. It is important to choose the correct type: TYPE_ONCE (one-time) or TYPE_ONCE_PER_USER (per user). Example code:

$coupon = \Bitrix\Sale\DiscountCouponsManager::generateCoupon(true); \Bitrix\Sale\Internals\DiscountCouponTable::add([ 'DISCOUNT_ID' => $discountId, 'ACTIVE' => 'Y', 'COUPON' => $coupon, 'TYPE' => \Bitrix\Sale\Internals\DiscountCouponTable::TYPE_ONCE, 'MAX_USE' => 1, ]); 
Checklist for Launching a Coupon Campaign - Check the `LAST_DISCOUNT` flag in the discount rule (should be N if coupons are to be combined). - Ensure the rule's validity period is active and not expired. - Test the order cancellation scenario — the coupon should return to the pool. - Set unique prefixes for coupons from different mailings. - Set usage limits (MAX_USE) for one-time coupons.

Why Might a Coupon Not Apply?

Most common reasons:

  • The discount rule is inactive or expired.
  • The 'Stop processing' flag (LAST_DISCOUNT = Y) blocks other coupons.
  • The usage limit has been reached.
  • The coupon is attached to a different user (type 3).

All these cases are checked during testing. On every project, we provide a guarantee for correct promo code operation.

Typical Mistakes When Setting Up Coupons

First: always check the LAST_DISCOUNT flag in the discount rule. If the coupon should be combined with other discounts, set it to N. Second: when generating in bulk, use unique prefixes — this eliminates code overlap from different mailings. Third: test the order cancellation scenario — the coupon must return to the pool.

Coupon Types

Type Description Application b_sale_discount_coupon TYPE
General (multi-use) One code, unlimited uses For campaigns without restrictions 1
Unique one-time One use for all For personal discounts 2
Unique per user One use for a specific user For loyalty 3

Process of Work

  1. Analytics — study business requirements, discount types, integrations with 1C and CRM.
  2. Design — create marketing rules, set up coupons, plan application logic.
  3. Implementation — program agents, modify the cart, integrate with mailings (e.g., via Bitrix24 REST API).
  4. Testing — check all scenarios: single coupon, multiple coupons, with other discounts, order cancellation.
  5. Deploy and Monitoring — set up reports and notifications for coupon usage.

What's Included

  • Audit of current marketing rules.
  • Design and creation of coupons (any type).
  • Writing agents for mass generation.
  • Integration with the cart and one-page checkout.
  • Template modification for coupon display.
  • Training for your managers on coupon management.
  • Technical documentation and post-launch support.

Estimated Timeline

Setting up one coupon type with a rule and input field — from 3 hours. A project with mass generation and mailing integration takes from 1 business day. The estimate is always free after reviewing the task.

We have been working with Bitrix for over 10 years and have completed more than 50 projects in setting up coupons and promo codes. Our solutions go through code review and are covered by a 30-day guarantee. Contact us to discuss your scenario and get an optimal solution. Order promo code setup: get a consultation and learn how to avoid errors and speed up campaign launch.

Helpful links: Marketing tools on Wikipedia, Official 1C-Bitrix guide.