Answer the question
In order to leave comments, you need to log in
How to add products to the order via api?
To add a product to a placed order, I use the CSaleBasket::Add function:
$arFields = array(
"PRODUCT_ID" => $_POST["id"],
"NAME" => htmlspecialchars_decode($name),
"PRICE" => $price,
"CURRENCY" => "RUB",
"ORDER_ID" => $_POST["order"],
"LID" => "s1",
"QUANTITY" => 1
);
$basketID = CSaleBasket::Add($arFields);
Answer the question
In order to leave comments, you need to log in
1. Remove line:
"NAME" => htmlspecialchars_decode($name),
"PRODUCT_ID" => $_POST["id"],
ID is passed here .
3. "PRICE" => $price,
remove, otherwise add'CUSTOM_PRICE' => 'Y',
Look at the example in the documentation for the method: https://dev.1c-bitrix.ru/api_help/sale/classes/csa... Offhand
:
- no module indication
- no provider indication
- no PRODUCT_PRICE_ID indication (if necessary)
But this is not enough, in addition to adding the product to the order, you additionally need to
- Create a shipment for it (or place it in an existing one)
- Create a payment for it (or change the first unpaid one, but a new one is better)
- recalculate the order (what if discounts appeared there)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question