Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Managed to do this by subscribing to the OnSaleComponentOrderOneStepPersonType event.
/bitrix/php_interface/init.php file code:
AddEventHandler("sale", "OnSaleComponentOrderOneStepPersonType", "selectSavedPersonType");
function selectSavedPersonType(&$arResult, &$arUserResult, $arParams)
{
global $USER;
if($USER->IsAuthorized())
{
$rsUser = $USER->GetByID($USER->GetID());
$arUser = $rsUser->Fetch();
$entity = $arUser['UF_ENTITY']; //поле принадлежности к юр. лицу
$personType = 0;
if ($entity) {
$personType = 2;
} else {
$personType = 1;
}
//очищаем текущее значение типа плательщика
foreach($arResult['PERSON_TYPE'] as $key => $type){
if($type['CHECKED'] == 'Y'){
$arResult['PERSON_TYPE'][$key]['CHECKED'] = '';
}
}
//устанавливаем новое значение типа плательщика
$arResult['PERSON_TYPE'][$personType]['CHECKED'] = 'Y';
$arUserResult['PERSON_TYPE_ID'] = $personType;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question