Setting up a discount on a 1C-Bitrix product bundle

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

Bundle Discount Configuration in 1C-Bitrix

A bundle discount — "buy a laptop + mouse + bag and get -15%" — is a standard tool for increasing average order value. In 1C-Bitrix this is implemented through the marketing module (cart-condition discounts) or through custom sales rules. There are enough nuances to consider: discount application order, overlap with other promotions, and displaying the discount on the product card.

Option 1: Discount via the built-in marketing module

Admin panel → Shop → Marketing → Discounts → Add discount.

The discount condition is configured through a visual builder: condition type "Product set", list the product IDs or SKUs from the bundle, set the minimum quantity for each. The discount value is a percentage or a fixed amount.

Built-in approach limitations: the condition builder is unintuitive for non-standard bundles, there is no discount display on the product card, and there is no "Build a bundle" block on the frontend.

Option 2: Custom sales rule

For complex bundles — handle the OnSaleOrderBeforeSaved event:

AddEventHandler('sale', 'OnBeforeOrderFinalAction', ['\Local\Pricing\BundleDiscount', 'apply']);
namespace Local\Pricing;

class BundleDiscount
{
    // Bundle definitions: [product_id => quantity]
    private static array $bundles = [
        'laptop_bundle' => [
            'products'       => [1001 => 1, 1045 => 1, 1078 => 1], // laptop, mouse, bag
            'discount_type'  => 'percent',
            'discount_value' => 15,
            'min_total'      => 0,
        ],
        'photo_bundle' => [
            'products'       => [2033 => 1, 2044 => 1], // camera + lens
            'discount_type'  => 'fixed',
            'discount_value' => 3000,
            'min_total'      => 0,
        ],
    ];

    public static function apply(\Bitrix\Sale\Order $order): void
    {
        $basket     = $order->getBasket();
        $basketMap  = self::buildBasketMap($basket);

        foreach (self::$bundles as $bundleKey => $bundle) {
            if (!self::isBundlePresent($basketMap, $bundle['products'])) {
                continue;
            }

            $discount = self::calculateDiscount($basket, $bundle);
            if ($discount <= 0) continue;

            // Apply discount via 1C-Bitrix mechanism
            $discountResult = new \Bitrix\Sale\Discount\Result\DiscountResult();
            $discountResult->setApplyResult([
                'DISCOUNT_VALUE'   => $discount,
                'DISCOUNT_TYPE'    => 'F', // fixed amount
                'DISCOUNT_RESULT'  => ['BASKET' => $basketMap],
            ]);

            $order->getDiscount()->setApplyResult($discountResult);
        }
    }

    private static function buildBasketMap(\Bitrix\Sale\Basket $basket): array
    {
        $map = [];
        foreach ($basket as $item) {
            $map[(int)$item->getProductId()] = (int)$item->getQuantity();
        }
        return $map;
    }

    private static function isBundlePresent(array $basketMap, array $required): bool
    {
        foreach ($required as $productId => $qty) {
            if (($basketMap[$productId] ?? 0) < $qty) {
                return false;
            }
        }
        return true;
    }
}

"Build a bundle" block on the product card

So the customer knows about the discount before checkout, a block with the bundle items is shown on the product card:

// In the product card result_modifier.php
$currentProductId = (int)$arResult['ID'];
$bundle = \Local\Pricing\BundleRepository::findByProduct($currentProductId);

if ($bundle) {
    $bundleProducts = \CIBlockElement::GetList(
        [],
        ['ID' => array_keys($bundle['products']), 'IBLOCK_ID' => CATALOG_IBLOCK_ID],
        false, false,
        ['ID', 'NAME', 'PREVIEW_PICTURE', 'DETAIL_PAGE_URL', 'CATALOG_PRICE_1']
    );

    $arResult['BUNDLE'] = [
        'discount'  => $bundle['discount_value'],
        'type'      => $bundle['discount_type'],
        'products'  => [],
    ];

    while ($p = $bundleProducts->GetNext()) {
        $arResult['BUNDLE']['products'][] = $p;
    }
}

In the product card template:

<?php if (!empty($arResult['BUNDLE'])): ?>
<div class="bundle-block">
    <div class="bundle-block__title">
        Buy the bundle and save
        <?php if ($arResult['BUNDLE']['type'] === 'percent'): ?>
            <?= $arResult['BUNDLE']['discount'] ?>%
        <?php else: ?>
            <?= number_format($arResult['BUNDLE']['discount'], 0, '', ' ') ?> ₽
        <?php endif ?>
    </div>
    <div class="bundle-block__items">
        <?php foreach ($arResult['BUNDLE']['products'] as $bundleItem): ?>
        <div class="bundle-block__item">
            <img src="<?= \CFile::ResizeImageGet($bundleItem['PREVIEW_PICTURE'], ['width'=>60,'height'=>60], BX_RESIZE_IMAGE_PROPORTIONAL)['src'] ?>"
                 alt="<?= htmlspecialchars($bundleItem['NAME']) ?>" width="60" height="60">
            <a href="<?= $bundleItem['DETAIL_PAGE_URL'] ?>"><?= htmlspecialchars($bundleItem['NAME']) ?></a>
        </div>
        <?php endforeach ?>
    </div>
    <button class="bundle-block__add-all js-add-bundle"
            data-bundle-ids="<?= implode(',', array_keys($arResult['BUNDLE']['products'])) ?>">
        Add all to cart
    </button>
</div>
<?php endif ?>

"Add entire bundle" button

document.querySelector('.js-add-bundle')?.addEventListener('click', async function() {
    const ids = this.dataset.bundleIds.split(',').map(Number);

    for (const id of ids) {
        await fetch('/local/ajax/cart-add.php', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ product_id: id, quantity: 1 }),
        });
    }

    // Update cart counter
    BX.onCustomEvent('OnBasketChange', [{}]);
});

Implementation timelines

Configuration Timeline
Discount via built-in marketing module 1 day
Custom handler + "Build a bundle" block 3–4 days
+ "Add all to cart" + savings display +1–2 days