E
E
Evgeny Nikolaev2019-07-04 15:26:50
1C-Bitrix
Evgeny Nikolaev, 2019-07-04 15:26:50

Bitrix. How to set the status of an order on D7 (at the time of order formation)?

First, a little about the code that already exists:
<?php
require $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';
use Bitrix\Main\Context,
Bitrix\Currency\CurrencyManager,
Bitrix\Sale\Order,
Bitrix\Sale\Basket,
Bitrix\Sale\Delivery,
Bitrix\Sale\PaySystem,
YandexCheckout\Client;
global $USER;
Bitrix\Main\Loader::includeModule("sale");
Bitrix\Main\Loader::includeModule("catalog");
// ... here are some actions to determine what kind of user
$order = Order::create($siteId, $USER->isAuthorized() ? $USER->GetID() : $userIdTpm);// Create an order
// ... all sorts of actions for assigning different data to an order
$basket = \Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(CSaleBasket::GetBasketUserID()), \Bitrix\Main\Context ::getCurrent()->getSite());// Get the current user 's basket
$order->setBasket($basket);// Apply the basket to the order
// ... more steps to assign different information to the basket
// .. and where it is supposed to set the order DN status "Waiting for processing" (how to do it via $order-> ? ), because if this is not done, the status N "Accepted, payment pending" is
set $order->doFinalAction(true);
$result = $order->save();
_____________________________
Note: I understand that you can assign a status through class methods, I'm interested in how to do it directly through the $order object?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2019-07-04
@nikolaevevge

$order->setField("STATUS_ID", "DN");

D
Damir, 2021-05-31
@ddem

$order->setField("CANCELED", "Y");
$order->save();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question