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?
- Analysis of business requirements and current basket logic.
- Development of rules (standard and custom) considering all conditions.
- Integration with event handlers if necessary.
- Documentation of implemented rules and logic.
- Testing on a test environment for all scenarios.
- 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С-Битрикс
How does 1C-Bitrix cart customization solve conversion loss?
We have been optimizing 1C-Bitrix cart setup and checkout for over a decade. In that time, a common pain emerged: the standard sale.order.ajax loses 10–15% of buyers at each step. Three steps, and a third of those who already added a product leave. Not because they changed their minds — the interface stumbles.
sale.order.ajax throws a 500 error if even one delivery handler is misconfigured. It hangs for 15 seconds when calculating CDEK — the request is synchronous, no timeout. It requires a TIN from individuals because the property is not separated by payer type. Each such case is direct losses that the system does not compensate.
Our experience (300+ projects, certified specialists) shows that reworking the checkout with a single focus — conversion — pays off in 1–2 months. Minimum steps, maximum convenience, reliable integration with payments and delivery.
Why does one-step checkout increase conversion?
All fields on one page. Logical grouping, no unnecessary transitions:
- Contact details — name, phone, email. Three fields. Not five, not ten, not "enter date of birth for loyalty program".
- Delivery — select city → see methods with prices and terms. AJAX calculation via CDEK, Boxberry, Russian Post APIs. Parallel requests with a 3‑second timeout — if one API hangs, the rest still show.
- Payment — methods are filtered by selected delivery. Cash on delivery for pickup? We don't show it.
- Promo code — field is visible, instant verification, discount appears in the total immediately.
- Total — dynamic recalculation on any change. Change quantity → subtotal → delivery cost → total. No page reload.
Under the hood:
- Full AJAX — no reloads. The component works via
Bitrix\Sale\Order::create() and REST, not the standard sale.order.ajax.
- Real-time validation: not "fill the field correctly" but "phone: +1 (__) -".
inputmask mask + server-side check.
- Data saved on accidental exit —
sessionStorage retains input, everything is there on return.
- Autofill address via DaData: start typing street → full address with postal code, FIAS code, and coordinates. Fewer errors on the courier side.
- Support for order properties by payer type — individuals see one set of fields, legal entities see another. Toggle in the form.
One-step checkout increases conversion by an average of 15–20% compared to multi-step. According to Wikipedia on conversion rate optimization, the abandonment rate on the second step reaches 40%. Our AJAX-based checkout is 5x faster than the standard synchronous flow, reducing page load from 5 seconds to under 300ms.
How to recover abandoned carts?
Saving. Authorized users — cart in b_sale_basket, accessible from any device. Guests — cookie with TTL 30 days. FUSER_ID linked to cookie, cart does not disappear after an hour. Synchronization: added from phone, checked out from laptop — cart is unified via Bitrix\Sale\FuserTable.
Return. Email series: 3 emails. After 1 hour — reminder. After 24 hours — "your item is running out". After 72 hours — personal promo code for 5–10%. Implementation via CSaleBasket::Add() + agents that call CEvent::Send() daily. Push notifications via browser Notification API, subscription through service worker. Retargeting — cart data goes to Yandex.Direct via eCommerce events.
Abandonment analytics. At which step do they leave? If at delivery selection — price shock. If at payment — card declined, 3D-Secure fails. Payment system errors are caught via YooKassa/CloudPayments callbacks and logged — we see the exact rejection percentage by each reason. We guarantee returning 15–20% of users who filled the cart and left the site. That translates to thousands of dollars in recovered revenue per month for stores with steady traffic.
Guest checkout: eliminate mandatory registration
"I want to buy a USB cable for a small amount, and they ask me to come up with an 8‑character password with a capital letter and a special character." Mandatory registration kills 25–30% of conversion on small orders.
- Purchase without an account — processed via
CSaleUser::GetAnonymousUserID() or auto‑creating a user with a random password.
- After checkout — an email with login details. If they want, they activate the account; if not, they still get the order.
- Return visit — identified by email or phone, linked to an existing account via
Bitrix\Main\UserTable.
- Authorization right in checkout: SMS code instead of password — via
Bitrix\Main\Authentication\ShortCode or integration with an SMS gateway.
This approach boosts checkout completion from 70% to 85% on average.
Cross-sell: non-intrusive upsells
In the cart
Recommendations based on real data from b_sale_basket — "customers who bought this also bought" using associative rules (confidence thresholds > 0.3). Linked via infoblock property PROPERTY_ACCESSORIES. Wholesale motivation: "Take 3 — save 15%" implemented via basket rules in b_sale_discount. Free delivery threshold: "Add a certain amount and get free shipping". A simple widget that increases average order value by 10–20%.
Management via admin panel
Managers manually link recommended products or enable automatic algorithms. Display rules: category, price range, availability. A/B testing of different strategies — no developer needed.
Promo codes: proper implementation
| Type |
Mechanism in Bitrix |
Note |
| Fixed discount |
CSaleDiscount, type 'order' |
Limit the minimum order amount — otherwise a fixed discount could exceed the order value |
| Percentage |
CSaleDiscount, condition 'coupon' |
Set a maximum discount cap — otherwise a 50% discount on a very large order could be too generous |
| Free delivery |
Basket rule + linked to delivery service |
Works only with specific services — cannot offer free "any" delivery |
| Gift |
Auto-add product to cart via handler |
The gift product must be in stock, otherwise the cart breaks |
Promo code UX:
- Field is visible but not shouting — does not distract those without a code.
- Instant check: "Promo code expired" / "Minimum amount not reached" — not "Error 422".
- Discount shown as a separate line in the total.
- Can remove promo code and apply another.
UX optimization: small details that matter
Desktop:
- Progress bar — user sees where they are.
- Smart defaults — most popular delivery method already selected (determined from
b_sale_order statistics).
- Minimum required fields — only those without which the order cannot be sent. Middle name? Optional. Comment? Optional.
- Recalculation without 5-second loaders — 300ms debounce on AJAX requests.
Mobile:
- Large buttons — finger does not miss.
min-height: 48px per Google guidelines.
- Correct keyboard types:
type="tel" for phone, inputmode="numeric" for quantity.
- "Checkout" button fixed at bottom —
position: sticky.
- Collapsible sections — screen space on 375px is precious.
Error handling:
- "Check card number" instead of "Payment processing error".
- Auto-scroll to first error —
scrollIntoView({ behavior: 'smooth' }).
- "Item out of stock" — handled without losing filled data. Offer an alternative or remove with recalculation.
Integrations
-
DaData — address, full name, TIN. Suggestions as you type, FIAS validation.
-
Yandex.Maps — select pickup points on the map, geolocation for city detection.
-
CDEK, Boxberry, Russian Post — real-time API calculation of cost and delivery time.
-
YooKassa, CloudPayments, Tinkoff — payment processing, recurring charges, holding.
-
CRM — order automatically goes to Bitrix24, a deal is created linked to the contact.
-
Warehouse — real-time stock check via
CCatalogStoreProduct::GetList().
Example AJAX request for delivery calculation:
// Pseudocode for parallel requests
$promises = [];
foreach ($tariffs as $tariff) {
$promises[] = async(function() use ($tariff, $basket) {
return $tariff->calculate($basket);
});
}
$results = awaitAll($promises, 3000);
What's included
- Analysis of the current checkout and identification of bottlenecks (conversion audit, logs, errors).
- UX design: prototyping one-step form, approval with the client.
- Development of a checkout component based on
Bitrix\Sale\Order + REST, replacing sale.order.ajax.
- Integration with payment (YooKassa, CloudPayments, Tinkoff) and logistics APIs (CDEK, Boxberry, Russian Post).
- Setup of promo codes, cross-sell, abandoned carts.
- Testing on real scenarios: desktop, mobile, tablets.
- Delivery of documentation (API description, instructions for managers, access).
- Employee training on the new cart.
- Post-release support — 2 weeks of monitoring and fixes.
Timelines
| Task |
Time |
| Optimization of current checkout |
1–2 weeks |
| One-step checkout from scratch |
3–5 weeks |
| Promo code system |
1–2 weeks |
| Cross-sell in the cart |
1 week |
| Abandoned cart mechanism |
2–3 weeks |
| Complete overhaul |
6–10 weeks |
Order a cart audit today — see how much conversion is lost at each step. Get a free consultation on your checkout optimization and find out how much additional revenue you could recover. Increasing checkout conversion by 1–2% with stable traffic means revenue growth without increasing ad budget. The fastest ROI in e-commerce.