Answer the question
In order to leave comments, you need to log in
CSaleBasket::Update does not update the number of products if the value is less than the current one, what could be causing this?
The CSaleBasket::Update() method does not update the quantity of items if the specified quantity is less than the current one (returns false). If you specify more, the record is updated. If you again specify the number of goods less than it was, then the record is not updated. Because of what it can be, how can you set any number of goods?
I am using the code below:
// Работает, если кол-во больше текущего
CSaleBasket::Update($id, array('QUANTITY' => $quantity));
// Работает, если кол-во больше изначального в заказе
$basketItem = $basket->getItemById($id);
$basketItem->setField('QUANTITY', $quantity);
$order->save();
Answer the question
In order to leave comments, you need to log in
$updateResult = CSaleBasket::Update($id, array('QUANTITY' => $quantity));
if(!$updateResult){
print_r($APPLICATION->LAST_ERROR);
}
$basketItem = $basket->getItemById($id);
$basketItem->setField('QUANTITY', $quantity);
$orderSaveResult = $order->save();
if(!$orderSaveResult->isSuccess()){
var_dump($orderSaveResult->getErrors());
}
foreach(GetModuleEvents("sale", "OnBeforeBasketUpdate", true) as $arEvent){
var_dump($arEvent);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question