C
C
countZer02020-08-11 10:33:24
1C-Bitrix
countZer0, 2020-08-11 10:33:24

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

2 answer(s)
F
Forever Extreme, 2020-08-11
@vechnokrainii

So you don't add the price change to the old one.
You need to add OldPrice to NewPrice

A
Anton, 2020-08-12
@anton99zel

//название товара не пишем
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());
}

To change an existing order:
$order = \Bitrix\Sale\Order::load(38); //загрузим заказ
.....//добавляем товары или производим другие действия
$order->save(); //сохраняем заказ

I didn't see in your code that for each product you set a new price

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question