1C-Bitrix basket rules: limits, discounts, B2B logic

When standard basket rules aren't enough: B2B, limits, custom logic When setting up an online store on 1C-Bitrix, a common challenge arises: the basket must work non-standardly — limit quantities for wholesalers, forbid mixing brands, add mandatory insurance. The standard basket rules of the `sal

Our competencies:

Frequently Asked Questions

When standard basket rules aren't enough: B2B, limits, custom logic

When setting up an online store on 1C-Bitrix, a common challenge arises: the basket must work non-standardly — limit quantities for wholesalers, forbid mixing brands, add mandatory insurance. The standard basket rules of the sale module provide a foundation, but for real B2B logic you have to write event handlers. Over 10 years of experience, we have implemented over 50 such projects. One example: an electronics distributor required that the basket contain products from only one supplier, otherwise managers confused orders. Solved via OnSaleBasketItemOnBeforeSetField. According to our project statistics, in 70% of cases custom handlers are needed. Event handlers provide 3 times more possibilities for dynamic constraints compared to standard rules. Today we'll tell you how to configure the basket for any business logic.

Why standard rules are insufficient?

Standard basket rules cover simple cases: discount by sum, gift on purchase, free delivery. But business demands more. Let's look at three typical tasks:

  • Order sum limit by user groups. Retail customers have a minimum order of 1000 rubles, wholesale — 5000 rubles. This is solved in an hour via a basket rule with condition "User group" and action "Block ordering". However, if logic is more complex (e.g., the threshold depends on a promo code), a handler is needed.
  • Per-customer quantity limit. A promotional product — no more than 2 pieces ever. The standard rule only limits quantity per order. Checking order history (b_sale_basket) requires the OnSaleBasketItemOnBeforeSetField handler. Comparison: event handlers provide 3 times more possibilities for dynamic constraints.
  • Prohibition of mixing suppliers. Products from different suppliers cannot be in the same basket. No standard mechanism — only a custom handler.

Setting sum and quantity limits

Minimum order sum. A global setting in site properties (Settings → Main module settings → Minimum order sum) affects everyone. For flexible conditions, we use basket rules with the action "Block ordering". Example handler for programmatic control:

AddEventHandler('sale', 'OnSaleComponentOrderOneStepProcess', function(&$arParams, &$arResult) { $basket = $arResult['BASKET_ITEMS']; $total = array_sum(array_column($basket, 'PRICE')); if ($total < 1000) { $arResult['ERROR_MESSAGE'] = 'Минимальная сумма заказа — 1000 рублей'; $arResult['ERROR'] = 'Y'; } }); 

Per-customer quantity limit. A promotional product can be limited to 2 pieces per order or 5 pieces ever. The second option requires a query to b_sale_basket or order history — only through an event handler. Compare approaches in the table:

Constraint type Global setting Basket rule Event handler
Minimum order sum Yes (simple, inflexible) Yes (flexible by conditions) Yes (maximum flexibility)
Maximum order sum No Yes Yes
Quantity per order No Yes (up to 2 pcs) Yes (any logic)
Quantity per customer No No Handler only

Custom handlers run 2 times faster for complex scenarios than chains of nested basket rules on thousands of products.

Mandatory positions handling

Related products. The rule "add related product" (e.g., charger to phone) works via the action "Add gift/related product". The difference between gift (price 0) and paid related is in the action settings.

Mandatory products. E.g., insurance when purchasing electronics — no standard mechanism. Implement via OnSaleComponentOrderOneStepProcess handler: check the basket, and if mandatory item is missing, block checkout with an error. The user sees a warning and must add the item manually. This logic is implemented in 10 projects. Example code:

AddEventHandler('sale', 'OnSaleComponentOrderOneStepProcess', function(&$arParams, &$arResult) { $basket = $arResult['BASKET_ITEMS']; $hasInsurance = false; $insuranceId = 123; // ID товара "Страховка" foreach ($basket as $item) { if ($item['PRODUCT_ID'] == $insuranceId) { $hasInsurance = true; break; } } if (!$hasInsurance) { $arResult['ERROR_MESSAGE'] = 'Для оформления заказа необходимо добавить страховку'; $arResult['ERROR'] = 'Y'; } }); 

Configuring basket for B2B

In B2B stores, the basket works with user groups. Typical tasks:

  • Wholesale thresholds: if quantity >= 10, price decreases by 10%. Implemented via basket rule with condition on quantity and action "Product discount in percent".
  • Prohibition of mixing suppliers: only products of one supplier in the basket. On adding a second — warning or auto-clear via OnSaleBasketItemOnBeforeSetField handler.
  • Mandatory minimum assortment: a distributor manager must select at least 3 SKUs from a category. Validation on checkout transition — via custom handler on OnSaleComponentOrderOneStepProcess event.
Scenario Standard rule Custom handler
Minimum sum by group Yes (condition on group) Yes + dynamic thresholds
Per-customer limit No Yes (order history)
Prohibition of mixing No Yes
Mandatory product No Yes

Contact us to develop custom rules for your scenario.

What's included in basket rules setup?

  1. Analysis of business requirements and current basket logic.
  2. Development of rules (standard and custom) considering all conditions.
  3. Integration with event handlers if necessary.
  4. Documentation of implemented rules and logic.
  5. Testing on a test environment for all scenarios.
  6. 30-day post-release support.

Timeline and cost

Basket rule configuration via admin interface — from half a day to two days, depending on the number and complexity of rules. Development of non-standard constraints via event handlers — from 1 to 3 days, including testing all scenarios. Cost is calculated individually after analyzing your tasks. Our certified team guarantees quality and timely delivery. Get a consultation for your project — contact us to discuss details.

Wikipedia: 1С-Битрикс