S
S
Sergey2015-08-11 12:19:02
PHP
Sergey, 2015-08-11 12:19:02

How to split the FIO order property into separate fields?

The store has created a FULL NAME checkout property.
The person enters three words respectively. Bitrix correctly enters only the First Name and Last Name into the user profile. Middle name is not recorded in the user profile. Why?
I decided to try to break the full name through the API in init.php and specify this data in the corresponding profile fields. But it doesn't work.
If you simply write some data to the standard fields (for example, a login to be an email), then it works like this:

AddEventHandler("main", "OnBeforeUserAdd", "OnAfterUserAddHandler");
function OnAfterUserAddHandler(&$arFields){
$arFields["LOGIN"] = $arFields["EMAIL"];
}

So I wanted to assign the broken name value to the NAME, LAST_NAME, SECOND_NAME fields here. But it doesn't work like that because the full name is a property of the order and apparently it can't be displayed in this handler (OnAfterUserAdd has only &$arFields)? If not, then we need to pull out the order ID, order properties, and then stick them into the profile? What handler to connect it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2015-08-12
@phper1785

Look here
bxapi.ru/src/?module_id=sale&name=CSaleUser::DoAut...
Well, the component itself. somewhere 168 line.
By default, you have a string that is broken by a space, and, accordingly, the Patronymic name is not recorded.
As a crutch, you can try to pass an array here via $_REQUEST
$_REQUEST['CODE_PROPERTY_TYPE_NAME_USER'] = ['NAME' => 'IVAN', 'FIRST_NAME' => 'IVANOV', 'SECOND_NAME' => 'IVANOVICH']
CODE_PROPERTY_TYPE_NAME_USER - property code actually from which the name of the new user is taken.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question