38 $orderClassName = $this->builder->getRegistry()->getOrderClassName();
42 $dataUserId = (int)($data[
"USER_ID"] ?? 0);
45 $currentUserId = $dataUserId;
48 $dataOldUserId = (int)($data[
"OLD_USER_ID"] ?? 0);
49 if ($dataOldUserId > 0)
51 $oldUserId = $dataOldUserId;
56 $order = $orderClassName::load($data[
"ID"]);
60 $this->builder->getErrorsContainer()->addError(
new Error(
Loc::getMessage(
"SALE_HLP_OBE_ORDER_NOT_LOADED")));
69 $currentUserId = (int)$this->builder->getOrder()->getUserId();
71 $formDataUserId = (int)($this->builder->getFormData()[
'USER_ID'] ?? 0);
72 $isChanged = ($formDataUserId > 0) && ($currentUserId !== $formDataUserId);
73 if ($currentUserId && $isChanged)
75 $paymentCollection = $this->builder->getOrder()->getPaymentCollection();
77 foreach ($paymentCollection as $payment)
79 if ($payment->isPaid())
81 $this->builder->getErrorsContainer()->addError(
new Error(
83 ,
'SALE_ORDEREDIT_ERROR_CHANGE_USER_WITH_PAID_PAYMENTS'));
88 if ($formDataUserId > 0)
90 $this->builder->getOrder()->setFieldNoDemand(
92 $this->builder->getUserId()
98 $personTypeId = (int)$this->builder->getOrder()->getPersonTypeId();
99 $resultLoading = \Bitrix\Sale\OrderUserProperties::loadProfiles($formDataUserId, $personTypeId);
100 if (!$resultLoading->isSuccess())
104 $profiles = $resultLoading->getData();
105 if (!is_array($profiles[$personTypeId]))
109 $currentProfile = current($profiles[$personTypeId]);
110 if (empty($currentProfile))
114 $values = $currentProfile[
'VALUES'];
115 $propertyCollection = $this->builder->getOrder()->getPropertyCollection();
116 $propertyCollection->setValuesFromPost(
117 [
'PROPERTIES' => $values],[]
124 if(is_array($this->builder->getFormData(
'PRODUCT')))
126 $this->builder->getBasketBuilder()
128 ->preliminaryDataPreparation()
129 ->removeDeletedItems()
130 ->itemsDataPreparation()
140 if ($fields[
'CUSTOM_PRICE_DELIVERY'] !==
'Y' && $shipment->getId() <= 0)
146 $priceDelivery = $fields[
'PRICE_DELIVERY'];
149 if ($fields[
'CUSTOM_PRICE_DELIVERY'] ===
'Y' || !isset($fields[
'BASE_PRICE_DELIVERY']))
151 $basePriceDelivery = $priceDelivery;
155 $basePriceDelivery = $fields[
'BASE_PRICE_DELIVERY'];
158 $fields[
'BASE_PRICE_DELIVERY'] = $basePriceDelivery;
159 $fields[
'PRICE_DELIVERY'] = $priceDelivery;
161 $res = $shipment->setFields($fields);
163 if(!$res->isSuccess())
165 $this->builder->getErrorsContainer()->addErrors($res->getErrors());
static getMessage($code, $replace=null, $language=null)