23 if(isset($data[
'SITE_ID']))
25 $siteId = $data[
'SITE_ID'];
29 $siteId = $data[
'LID'];
34 $this->builder->getErrorsContainer()->addError(
new Error(
Loc::getMessage(
"SALE_HLP_OBN_SITEID_ABSENT")));
41 if (isset($data[
'USER_ID']))
43 $currentUserId = (int)$data[
'USER_ID'];
46 if (isset($data[
'OLD_USER_ID']))
48 $oldUserId = (int)$data[
'OLD_USER_ID'];
52 if (isset($data[
'CURRENCY']))
54 $currency = $data[
'CURRENCY'];
59 $orderClassName = $this->builder->getRegistry()->getOrderClassName();
60 $order = $orderClassName::create($siteId, $currentUserId, $currency);
64 $this->builder->getErrorsContainer()->addError(
new Error(
Loc::getMessage(
"SALE_HLP_OBE_ORDER_NOT_CREATED")));
105 $this->builder->getOrder()->setFieldNoDemand(
107 $this->builder->getUserId()
110 $currentUserId = (int)$this->builder->getOrder()->getUserId();
111 $oldFormDataUserId = (int)$this->builder->getFormData(
'OLD_USER_ID');
113 $currentPersonTypeId = (int)$this->builder->getOrder()->getPersonTypeId();
114 $oldPersonTypeId = (int)$this->builder->getFormData(
'OLD_PERSON_TYPE_ID');
116 $reloadProfile = $oldFormDataUserId > 0 && $currentUserId !== $oldFormDataUserId;
117 if (!$reloadProfile && $oldPersonTypeId > 0 && $oldPersonTypeId !== $currentPersonTypeId)
119 $reloadProfile =
true;
124 $resultLoading = \Bitrix\Sale\OrderUserProperties::loadProfiles($currentUserId, $currentPersonTypeId);
125 if (!$resultLoading->isSuccess())
129 $profiles = $resultLoading->getData();
130 if (empty($profiles) || !is_array($profiles))
134 $currentProfile = current($profiles[$currentPersonTypeId]);
135 if (empty($currentProfile))
139 $values = $currentProfile[
'VALUES'];
140 $propertyCollection = $this->builder->getOrder()->getPropertyCollection();
141 $propertyCollection->setValuesFromPost(
142 [
'PROPERTIES' => $values],[]