# sale.basketitem.updateCatalogProduct

URL: https://chugunov.pro/api-bitrix24/sale/basket-item/sale-basket-item-update-catalog-product/
Проверено на Битрикс24 REST API, обновлено 11.09.2026 (ревизия источника fb39d6c).
Источник: официальная документация Битрикс24 (bitrix-tools/b24-rest-docs, лицензия MIT, © Bitrix). Справочник независимый, официальной документацией не является.

Изменить позицию корзины (товар из каталога) существующего заказа
Scope: `sale`
Кто может выполнять метод: администратор

## Описание

Метод `sale.basketitem.updateCatalogProduct` изменяет позицию корзины с товаром из каталога в существующем заказе.

## Параметры

- `id` `sale_basket_item.id` — обязательный. Идентификатор элемента (позиции) корзины. Может быть получен методами [sale.basketitem.addCatalogProduct](https://chugunov.pro/api-bitrix24/sale/basket-item/sale-basket-item-add-catalog-product/) и [sale.basketitem.list](https://chugunov.pro/api-bitrix24/sale/basket-item/sale-basket-item-list/)
- `fields` `object` — обязательный. Объект с изменяемыми полями

### Параметр fields

- `sort` `integer` — необязательный. Положение в списке позиций заказа
- `quantity` `double` — обязательный. Количество товара
- `xmlId` `string` — необязательный. Внешний код позиции корзины

## Ответ

HTTP-статус: 200

```json
{
    "result": {
        "basketItem": {
            "basePrice": 1234,
            "canBuy": "Y",
            "catalogXmlId": "FUTURE-ERP-CATALOG",
            "currency": "RUB",
            "customPrice": "N",
            "dateInsert": "2024-04-22T16:23:43+02:00",
            "dateUpdate": "2024-04-22T16:32:26+02:00",
            "dimensions": "a:3:{s:5:\"WIDTH\";N;s:6:\"HEIGHT\";N;s:6:\"LENGTH\";N;}",
            "discountPrice": 124,
            "id": 6783,
            "measureCode": "796",
            "measureName": "шт",
            "name": " Разработка дизайна ",
            "orderId": 5147,
            "price": 1110,
            "roductid": 4347,
            "productXmlId": "4347",
            "properties": [],
            "quantity": 4,
            "reservations": [],
            "sort": 100,
            "type": 2,
            "vatIncluded": "N",
            "vatRate": null,
            "weight": 0,
            "xmlId": "bx_662672ef370c6"
        }
    },
    "total": 1,
    "time": {
        "start": 1713796344.951712,
        "finish": 1713796346.586924,
        "duration": 1.6352121829986572,
        "processing": 0.6428370475769043,
        "date_start": "2024-04-22T16:32:24+02:00",
        "date_finish": "2024-04-22T16:32:26+02:00",
        "operating": 0
    }
}
```

### Возвращаемые данные

- `result` `object`. Корневой элемент ответа
- `basketItem` `sale_basket_item`. Объект с данными созданного элемента (позиции) корзины
- `total` `integer`. Число обработанных записей
- `time` `time`. Информация о времени выполнения запроса

## Ошибки

HTTP-статус: 400

```json
{
    "error":0,
    "error_description":"error"
}
```

- `200140400006` — `Module catalog is not exists`
  Отсутствует модуль Торговый каталог (catalog)
- `200140400001` — `basket item is not exists`
  Не найдена позиция корзины
- `200140400008` — `Required fields: fields[ORDER_ID]`
  Не указан идентификатор заказа
- `200140400009` — `Order not found`
  Заказ не найден
- `200140400011` — `Currency must be the currency of the order`
  Валюта позиции не совпадает с валютой заказа
- `200040300010` — Недостаточно прав для изменения
- `100` — Не указаны обязательные параметры
- `0` — Другие ошибки (например, фатальные ошибки)

## Примеры запроса

### cURL (Webhook)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":6783,"fields":{"quantity":4}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.basketitem.updateCatalogProduct
```

### cURL (OAuth)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":6783,"fields":{"quantity":4},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.basketitem.updateCatalogProduct
```

### JS (TS)

```ts
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame, ISODate } from '@bitrix24/b24jssdk'

declare const $b24: B24Frame

// Shape of the payload returned in result (match the "response handling" section of the page)
type BasketItemUpdateResult = {
  basketItem: {
    basePrice: number,
    canBuy: string,
    catalogXmlId: string,
    currency: string,
    customPrice: string,
    dateInsert: ISODate | null,
    dateUpdate: ISODate | null,
    dimensions: string,
    discountPrice: number,
    id: number,
    measureCode: string,
    measureName: string,
    name: string,
    orderId: number,
    price: number,
    productXmlId: string,
    quantity: number,
    sort: number,
    type: number,
    vatIncluded: string,
    vatRate: number | null,
    weight: number,
    xmlId: string,
  },
}

try {
  const response = await $b24.actions.v2.call.make<BasketItemUpdateResult>({
    method: 'sale.basketitem.updateCatalogProduct',
    params: {
      id: 6783,
      fields: {
        quantity: 4,
      },
    },
    requestId: Text.getUuidRfc4122()
  })

  // The payload is available only on a successful response
  if (!response.isSuccess) {
    console.error(response.getErrorMessages().join('; '))
  } else {
    const result = response.getData()!.result
    console.info(result.basketItem.id, result.basketItem.name, result.basketItem.quantity)
  }
} catch (error) {
  // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
  console.error(error)
}
```

### JS (UMD)

```html
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
  async function updateCatalogProduct() {
    try {
      // Initialize the SDK inside a Bitrix24 frame
      const $b24 = await B24Js.initializeB24Frame()

      const response = await $b24.actions.v2.call.make({
        method: 'sale.basketitem.updateCatalogProduct',
        params: {
          id: 6783,
          fields: {
            quantity: 4,
          },
        },
        requestId: B24Js.Text.getUuidRfc4122()
      })

      // The payload is available only on a successful response
      if (!response.isSuccess) {
        console.error(response.getErrorMessages().join('; '))
        return
      }

      const result = response.getData().result
      console.info(result.basketItem.id, result.basketItem.name, result.basketItem.quantity)
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  }

  document.addEventListener('DOMContentLoaded', updateCatalogProduct)
</script>
```

### Python

```python
from b24pysdk.errors import BitrixAPIError, BitrixSDKException

fields = {
    "quantity": 4,
}

try:
    bitrix_response = client.sale.basketitem.update_catalog_product(
        bitrix_id=6783,
        fields=fields,
    ).response
    result = bitrix_response.result
    print(result)
except BitrixAPIError as error:
    print(
        "Ошибка Bitrix API",
        f"error: {error.error}",
        f"error_description: {error.error_description}",
        sep="\n",
    )
except BitrixSDKException as error:
    print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
    print(f"Непредвиденная ошибка: {error}")
```

### PHP

```php
try {
    $response = $b24Service
        ->core
        ->call(
            'sale.basketitem.updateCatalogProduct',
            [
                'id'     => 6783,
                'fields' => [
                    'quantity' => 4,
                ],
            ]
        );

    $result = $response
        ->getResponseData()
        ->getResult();

    echo 'Success: ' . print_r($result, true);
    // Нужная вам логика обработки данных
    processData($result);

} catch (Throwable $e) {
    error_log($e->getMessage());
    echo 'Error updating catalog product: ' . $e->getMessage();
}
```

### BX24.js

```js
BX24.callMethod(
    "sale.basketitem.updateCatalogProduct",
    {
        id: 6783,
        fields: {
            quantity: 4,
        }
    },
)
    .then(
        function(result)
        {
            if (result.error())
            {
                console.error(result.error());
            }
            else
            {
                console.log(result.data());
            }
        },
        function(error)
        {
            console.info(error);
        }
    );
```

### PHP CRest

```php
require_once('crest.php');

$result = CRest::call(
    'sale.basketitem.updateCatalogProduct',
    [
        'id' => 6783,
        'fields' => [
            'quantity' => 4,
        ]
    ]
);

echo '<PRE>';
print_r($result);
echo '</PRE>';
```

### Go

```go
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "sale.basketitem.updateCatalogProduct", b24.Params{
	"id": 6783,
	"fields": b24.Params{
		"quantity": 4,
	},
})
if err != nil {
	return fmt.Errorf("sale.basketitem.updateCatalogProduct: %w", err)
}

// Метод заворачивает ответ в объект с ключом "basketItem".
raw, ok := b24.Unwrap(res.Result, "basketItem")
if !ok {
	return fmt.Errorf("в ответе нет ключа basketItem")
}

var item struct {
	BasePrice    int    `json:"basePrice"`
	CanBuy       string `json:"canBuy"`
	CatalogXmlID string `json:"catalogXmlId"`
	Currency     string `json:"currency"`
	CustomPrice  string `json:"customPrice"`
	DateInsert   string `json:"dateInsert"`
}
if err := json.Unmarshal(raw, &item); err != nil {
	return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.BasePrice, item.CanBuy)
```

Оригинал в официальной документации: https://apidocs.bitrix24.ru/api-reference/sale/basket-item/sale-basket-item-update-catalog-product.html
