Answer the question
In order to leave comments, you need to log in
Price recalculation when creating a new order?
Hello !
Tell me how to write a custom price to it when creating a new order.
Answer the question
In order to leave comments, you need to log in
So you don't add the price change to the old one.
You need to add OldPrice to NewPrice
//название товара не пишем
Bitrix\Main\Loader::includeModule("catalog");
$fields = [
'PRODUCT_ID' => $item[offer_id], // ID товара, обязательно
'QUANTITY' => $item[quantity],
'CURRENCY' => Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'LID' => Bitrix\Main\Context::getCurrent()->getSite(),
'PRICE' => $item[price], //твоя кастомная цена
'CUSTOM_PRICE' => 'Y',
];
$r = Bitrix\Catalog\Product\Basket::addProduct($fields);
if (!$r->isSuccess()) {
var_dump($r->getErrorMessages());
}
$order = \Bitrix\Sale\Order::load(38); //загрузим заказ
.....//добавляем товары или производим другие действия
$order->save(); //сохраняем заказ
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question