Answer the question
In order to leave comments, you need to log in
How to programmatically reduce the number of items in the cart?
How to programmatically reduce the number of items in the cart? Does not allow to reduce due to the binding of goods to shipments. I use the "CSaleBasket::Update" method.
Answer the question
In order to leave comments, you need to log in
Alexey Emelyanov :
You probably need to delete the shipping document first.
// Читаем заказ, читаем корзину
$order= \Bitrix\Sale\Order::load( 6924 );
$basket= $order->getBasket();
$basket_items= $basket->getBasketItems();
/**
* @var $bi \Bitrix\Sale\BasketItem
*/
foreach ( $basket_items as $bi ) {
$quantity_current= $bi->getField( 'QUANTITY' );
//Приходит в формате "3.000"
$quantity_current++;
$quantity_current= $bi->setField( 'QUANTITY', $quantity_current );
$save_result= $bi->save();
if ( !$save_result->isSuccess() ) {
ShowError( $save_result->getErrorMessages() );
exit;
}
}
Does not allow to reduce due to the binding of goods to shipments- show the exact wording of the error that the api returns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question