A
A
Anton2019-01-30 03:46:33
1C-Bitrix
Anton, 2019-01-30 03:46:33

How to take into account the rules of the cart when placing an order through the API?

Checkout via API (not D7) works like this:

$arFields = 
            array(
               'LID' => mr,
               'PERSON_TYPE_ID' => 3,
               'PAYED' => "N",
               'CANCELED' => "N",
               'STATUS_ID' => "N",
               'ALLOW_DELIVERY' => 'N',
               'PRICE' => $allik, 
               'CURRENCY' => "RUR",
               'USER_ID' => $userId,
               'PAY_SYSTEM_ID' => $_POST["pay"],
               'DELIVERY_ID' => $_POST["DELIVERY"],
               'PRICE_DELIVERY' => $_POST["autodos"],
 );
$order_id = CSaleOrder::Add($arFields);
CSaleBasket::OrderBasket($order_id, $FUSER_ID, SITE_ID);

Everything is wonderful and good.
But here's the trouble:
This code takes into account the discount on the product, but does not take into account the "rules for working with the basket" at all.
I created a rule, if there is a specific product in the cart, then we make a 100% discount on the second product.
I get two products in the cart, the price and amount are displayed correctly, i.e. one product with a price, and the second with a zero price. But the registration of the goods and the order in the admin panel does not see this discount.
How to apply cart rules in API?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question