A
A
Ainur Valiev2018-03-19 15:55:28
1C-Bitrix
Ainur Valiev, 2018-03-19 15:55:28

Why are product discounts not calculated?

such a problem: I add products via the CSaleBasket::Add API, but discounts for them in the basket are not calculated, even when the basket is updated.
Discounts are set in Marketing - Product Marketing - Rules for working with the
basket5aafbd06aa1b6837371618.png
5aafbd1898355481285439.png

$basket = Bitrix\Sale\Basket::loadItemsForFUser(Bitrix\Sale\Fuser::getId(), Bitrix\Main\Context::getCurrent()->getSite());
        $items = $basket->getBasketItems();
        if(!empty($items)) {
            $discount_fuser = new Bitrix\Sale\Discount\Context\Fuser();
            $discount = \Bitrix\Sale\Discount::buildFromBasket(
                $basket,
                $discount_fuser
            );
            $discount->calculate();
            $discount->save();
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question