D
D
Dmitry2016-03-01 14:50:42
1C-Bitrix
Dmitry, 2016-03-01 14:50:42

How to programmatically change the payer type in bitrix:sale.order.ajax?

On the checkout page, you need to remove the payer type selection radiobuttons and set the payer type programmatically. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-03-02
@koyard

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;
    }
}

S
Sergey, 2016-03-01
@gangstarcj

You can just hide it with css and use jquery to select$("#PERSON_TYPE_2").click();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question