Март 19, 2024
Получение списка заказов, объекта заказа и т.д. с помощью класса "\Bitrix\Sale\Order" и др.
Получить объект заказа с идентификатором 12:
Получить объект заказа по номеру заказа:
Получить список заказов пользователя с идентификатором 3 сайта 's1':
$registry = \Bitrix\Sale\Registry::getInstance(\Bitrix\Sale\Registry::REGISTRY_TYPE_ORDER);
$orderClassName = $registry->getOrderClassName();
$orderResult = $orderClassName::getList(array(
'filter' => [
'USER_ID' => 3,
'LID' => 's1',
],
'select' => ['ID'],
'order' => ['ID' => 'DESC'],
));
while($row = $orderResult->fetch())
{
$order = \Bitrix\Sale\Order::load($row['ID']);
// работаем с объектом заказа в $order
}
Также можно воспользоваться функцией "\Bitrix\Sale\Order::loadByFilter" для достижения того же результата:
Если нужно получить все поля заказа (см. перечень полей в конце страницы):
Цикл по свойствам заказа:
foreach($order->getPropertyCollection() as $propertyValue)
{
// $propertyValue->getField('VALUE')
// $propertyValue->getField('NAME')
// $propertyValue->getField('CODE')
// $propertyValue->getField('ORDER_PROPS_ID')
// $propertyValue->getField('ID')
// $property = $propertyValue->getProperty();
// or
// $property = $propertyValue->getPropertyObject();
// $property->getId()
// $property->getPersonTypeId()
// $property->isUtil()
// $property->isRequired()
// $property->getType()
// $property->getDescription()
// $property->getRelations()
// $property->getName()
// $property->getGroupId()
}
Получение объекта значения свойства заказа по символьному коду свойства:
Получение объекта значения свойства заказа по идентификатору свойства:
Получение объекта значения ключевых свойств заказа:
$propertyCollection = $order->getPropertyCollection();
$propertyValue = $propertyCollection->getAddress()
$propertyValue = $propertyCollection->getPhone()
$propertyValue = $propertyCollection->getProfileName()
$propertyValue = $propertyCollection->getTaxLocation()
$propertyValue = $propertyCollection->getDeliveryLocationZip()
$propertyValue = $propertyCollection->getDeliveryLocation()
$propertyValue = $propertyCollection->getPayerName()
$propertyValue = $propertyCollection->getUserEmail()
Перечень полей заказа:
/*
Array
(
[ID] => 2530
[LID] => s1
[ACCOUNT_NUMBER] => 2530
[TRACKING_NUMBER] =>
[PAY_SYSTEM_ID] => 8
[DELIVERY_ID] => 7
[DATE_INSERT] => Bitrix\Main\Type\DateTime Object
(
[userTimeEnabled:protected] => 1
[value:protected] => DateTime Object
(
[date] => 2024-03-19 23:19:49.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_UPDATE] => Bitrix\Main\Type\DateTime Object
(
[userTimeEnabled:protected] => 1
[value:protected] => DateTime Object
(
[date] => 2024-03-19 23:19:57.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[PERSON_TYPE_ID] => 1
[USER_ID] => 4
[PAYED] => N
[IS_SYNC_B24] => N
[DATE_PAYED] =>
[EMP_PAYED_ID] =>
[DEDUCTED] => N
[DATE_DEDUCTED] =>
[EMP_DEDUCTED_ID] =>
[REASON_UNDO_DEDUCTED] =>
[STATUS_ID] => N
[DATE_STATUS] => Bitrix\Main\Type\DateTime Object
(
[userTimeEnabled:protected] => 1
[value:protected] => DateTime Object
(
[date] => 2024-03-19 23:19:47.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[EMP_STATUS_ID] => 4
[MARKED] => N
[DATE_MARKED] => Bitrix\Main\Type\DateTime Object
(
[userTimeEnabled:protected] => 1
[value:protected] => DateTime Object
(
[date] => 2024-03-19 23:19:49.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[EMP_MARKED_ID] => 4
[REASON_MARKED] =>
[PRICE_DELIVERY] => 0
[ALLOW_DELIVERY] => N
[DATE_ALLOW_DELIVERY] =>
[EMP_ALLOW_DELIVERY_ID] =>
[RESERVED] => N
[PRICE] => 395
[CURRENCY] => RUB
[DISCOUNT_VALUE] => 0
[TAX_VALUE] => 0.00
[SUM_PAID] => 0
[USER_DESCRIPTION] =>
[PAY_VOUCHER_NUM] =>
[PAY_VOUCHER_DATE] =>
[ADDITIONAL_INFO] =>
[COMMENTS] =>
[COMPANY_ID] =>
[CREATED_BY] => 4
[RESPONSIBLE_ID] =>
[STAT_GID] =>
[DATE_PAY_BEFORE] =>
[DATE_BILL] =>
[IS_RECURRING] => N
[RECURRING_ID] =>
[LOCKED_BY] =>
[DATE_LOCK] =>
[RECOUNT_FLAG] => Y
[AFFILIATE_ID] =>
[DELIVERY_DOC_NUM] =>
[DELIVERY_DOC_DATE] =>
[UPDATED_1C] => N
[ORDER_TOPIC] =>
[XML_ID] => 16000000-0000-0000-0000-000000002530
[ID_1C] =>
[VERSION_1C] =>
[VERSION] => 2
[EXTERNAL_ORDER] => N
[STORE_ID] =>
[CANCELED] => N
[EMP_CANCELED_ID] =>
[DATE_CANCELED] =>
[REASON_CANCELED] =>
[BX_USER_ID] => 2c2e3932017975f2cdfe84c0744f044e
[SEARCH_CONTENT] =>
[RUNNING] => N
)
*/