Answer the question
In order to leave comments, you need to log in
Displaying user data in the Bitrix order form: site management, how to do it?
How to make the data from the user profile be pulled into the checkout form? In short, the user enters his data during registration, then logs in and when placing an order, he has to enter his data again, how can I make sure that the data is automatically substituted in the appropriate fields as shown in the figure:
Should this be done using the OnSaleComponentOrderOneStepPersonType event?
If someone knows how to write such an event handler, please help, explain!
Answer the question
In order to leave comments, you need to log in
I see two options:
1) When registering a user, create a buyer profile CSaleOrderUserProps::Add . And the fields filled in by the user should be added to the fields of the created profile CSaleOrderUserPropsValue::Add . In the sale.order.ajax component, you will need to allow the use of buyer profiles.
2) When placing an order through sale.order.ajax. It has an OnSaleComponentOrderJsData event . This event is called after the array with data for the javascript handler has been initialized. Catch this event and add the desired values to the order properties.
I get in result_modifier.php, here is the code:
global $USER;
$arResult["MY_USER_PROPS"] = array();
$arResult["MY_USER_PROPS"]["FIRST_NAME"] = "";
$arResult["MY_USER_PROPS"]["MIDDLE_NAME"] = "";
$arResult["MY_USER_PROPS"]["LAST_NAME"] = "";
$arResult["MY_USER_PROPS"]["EMAIL"] = "";
$arResult["MY_USER_PROPS"]["PHONE"] = "";
$arResult["MY_USER_PROPS"]["ADDRESS"] = "";
$arResult["MY_USER_PROPS"]["COMPANY_NAME"] = "";
$arResult["MY_USER_PROPS"]["UR_ADDRESS"] = "";
$arResult["MY_USER_PROPS"]["INN"] = "";
$arResult["MY_USER_PROPS"]["KPP"] = "";
$userId = CUser::GetID();
if ($userId > 0) {
$filter = array("ID"=>$userId);
$rsUsers = CUser::GetList(($by = ""), ($order = "desc"), $filter,array("SELECT"=>array("UF_*")));
$arUser = $rsUsers->fetch();
foreach ($arUser as $key => $val) {
$arResult["MY_USER_PROPS"][$key] = $val;
}
}
$userId = CUser::GetID();
if ($userId > 0) {
$filter = array("ID"=>$userId);
$rsUsers = CUser::GetList(($by = ""), ($order = "desc"), $filter,array("SELECT"=>array("UF_*")));
$arUser = $rsUsers->fetch();
if (isset($arUser["NAME"])) {
$arResult["MY_USER_PROPS"]["FIRST_NAME"] = $arUser["NAME"];
}
if (isset($arUser["
if (isset($arUser["LAST_NAME"])) {
$arResult["MY_USER_PROPS"]["LAST_NAME"] = $arUser["LAST_NAME"];
}
if (isset($arUser["EMAIL"])) {
$arResult["MY_USER_PROPS"]["EMAIL"] = $arUser["EMAIL"];
}
if (isset($arUser["PERSONAL_PHONE"])) {
$arResult["MY_USER_PROPS"]["PHONE"] = $arUser["PERSONAL_PHONE"];
}
if (isset($arUser["PERSONAL_STREET"])) {
$arResult["MY_USER_PROPS"]["ADDRESS"] = $arUser["PERSONAL_STREET"];
}
if (isset($arUser["WORK_COMPANY"])) {
$arResult["MY_USER_PROPS"]["COMPANY_NAME"] = $arUser["
if (isset($arUser["UF_INN"])) {
$arResult["MY_USER_PROPS"]["INN"] = $arUser["UF_INN"];
}
if (isset($arUser["UF_KPP"])) {
$arResult["MY_USER_PROPS"]["KPP"] = $arUser["UF_KPP"];
}
}
// End of getting information about the user
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question