X
X
xuxubla2016-02-12 09:01:44
CMS
xuxubla, 2016-02-12 09:01:44

Why does the CSaleBasket::Add method overwrite delivery information?

I import orders from another site - it's not the most rewarding thing, since some of the goods are not in the store already. As for adding the order itself:

CModule::IncludeModule('iblock');
CModule::IncludeModule('sale');
$arFields = array(
   "LID" => "s1",
   "PERSON_TYPE_ID" => 1,
   "PAYED" => "N",
   "CANCELED" => "N",
   "STATUS_ID" => "N",
   "PRICE" => 800.00,
   "CURRENCY" => "RUB",
   "USER_ID" => 1,
   "PAY_SYSTEM_ID" => 1,
   "PRICE_DELIVERY" => 500.00,
   "USER_DESCRIPTION" => "Пробный заказ"
)
$ORDER_ID = CSaleOrder::Add($arFields);

This item adds shipping. But as soon as I add a product to this order:
$arFields = array(
    "PRODUCT_ID" => 1,
    "PRICE" => 300.00,
    "CURRENCY" => "RUB",
    "QUANTITY" => 1,
    "ORDER_ID" => $ORDER_ID,
    "LID" => "s1",
    "NAME" => "Чемодан кожаный",
  );
CSaleBasket::Add($arFields);

The cost of delivery and the amount of the entire order disappears, only the cost of the goods remains.
I decided to update all this with the Update function:
$arFields = array(
   "PAYED" => "N",
   "CANCELED" => "N",
   "STATUS_ID" => "N",
   "PRICE" => 800.00,
   "CURRENCY" => "RUB",
   "USER_ID" => 1,
   "PAY_SYSTEM_ID" => 1,
   "DELIVERY_ID" => 1,
   "PRICE_DELIVERY" => 500.00,
);
$ORDER_ID = CSaleOrder::Update($ORDER_ID, $arFields);

The total amount is added, but the shipping amount is not. What can be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xuxubla, 2016-02-12
@xuxubla

It's decided. You do not need to immediately link the product to the order. First, just to the basket, and then CSaleBasket::OrderBasket.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question