A
A
Andrey2017-08-21 10:20:28
PHP
Andrey, 2017-08-21 10:20:28

The basket is not updated by the CSaleBasket::Update method on 1c bitrix?

Good afternoon!
The site was made on 1c bitrix and faced such a problem that when there is a product in the basket and its quantity is 1, I want to update the quantity of this product using the CSaleBasket::Update method, but nothing happens.
That is, I use:

$ids =83117; //id товара, которого надо изменить количество в корзине
  $quns = 1; //количество, на которое надо изменить

         $arFields = array(
       "QUANTITY" => $quns
    );

    CSaleBasket::Update($ids, $arFields);

But nothing happens, the product is not updated, I even checked the php debugger in the Bitrix admin panel, it also does not work.
Maybe someone knows what it could be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Emelyanov, 2017-08-21
@Andrey_Tech

$ids =83117; //id товара, которого надо изменить количество в корзине

- To update the number of goods, you need to pass not the id of the product , but the id of the cart record .
see example from documentation:
<?
// Изменим количество товара в записи $ID корзины на 2 штуки и отложим товар
$arFields = array(
   "QUANTITY" => 2,
   "DELAY" => "Y"
);
CSaleBasket::Update($ID, $arFields);
?>

A
Ainur Valiev, 2017-12-05
@vaajnur

I also do not update the quantity in the basket using the CSaleBasket:Update($arFields) method, but the updated one falls into the order. the NAME field is updated without problems, by the way, which is marked as mandatory in the doc.
look away script.js
postData['QUANTITY_' + items.rows[i].id] = BX('QUANTITY_' + items.rows[i].id).value;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question