Answer the question
In order to leave comments, you need to log in
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
basket
$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 questionAsk a Question
731 491 924 answers to any question