- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/helpers/order/builder/orderbuilder.php
- Класс: BitrixSaleHelpersOrderBuilderOrderBuilder
- Вызов: OrderBuilder::createUserFromFormData
protected function createUserFromFormData()
{
$errors = [];
$orderProps = $this->order->getPropertyCollection();
if ($email = $orderProps->getUserEmail())
{
$email = $email->getValue();
}
if ($name = $orderProps->getPayerName())
{
$name = $name->getValue();
}
if ($phone = $orderProps->getPhone())
{
$phone = $phone->getValue();
}
if ($this->getSettingsContainer()->getItemValue('searchExistingUserOnCreating'))
{
$userId = $this->searchExistingUser($email, $phone);
}
if (!isset($userId))
{
$userId = $this->searchExistingUser($email, $phone);
}
if (!isset($userId))
{
$userId = CSaleUser::DoAutoRegisterUser(
$email,
$name,
$this->formData['SITE_ID'],
$errors,
[
'PERSONAL_PHONE' => $phone,
'PHONE_NUMBER' => $phone,
]
);
if (!empty($errors))
{
foreach ($errors as $val)
{
$this->errorsContainer->addError(new Error($val['TEXT'], 0, 'USER'));
}
}
else
{
// ToDo remove it? when to authorize buyer?
global $USER;
$USER->Authorize($userId);
}
}
return $userId;
}