A
A
Andrey2017-05-29 16:23:07
1C-Bitrix
Andrey, 2017-05-29 16:23:07

How to make an exception 1c bitrix?

How to make an exception if the user registers by filling in the fields in the order on the checkout page, since in this case Bitrix itself creates a delivery profile

//создаём профиль
      //PERSON_TYPE_ID - идентификатор типа плательщика, для которого создаётся профиль
      $arProfileFields = array(
         "USER_ID" => $arFields['ID'],
   "NAME" => $arFields['NAME'],
         "PERSON_TYPE_ID" => 1
      );
    { 
  
   $PROFILE_ID = CSaleOrderUserProps::Add($arProfileFields);
      
      //если профиль создан
перед  $PROFILE_ID = CSaleOrderUserProps::Add($arProfileFields);

it is necessary to set the condition that if the user already has a delivery profile, then do not create it,
how can this be implemented in the code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Pavlov, 2017-05-29
@Andrey_Tech

An exception is when some kind of abnormal situation occurs, there is nothing abnormal right there, so there is no need to throw an exception. You just need to add a check. What prevents you from getting a list of user profiles, and based on the results, decide whether to create a new profile or not?
https://dev.1c-bitrix.ru/api_help/sale/classes/csa...
Why don't you want to create a new profile? What if the user enters a different shipping address? Perhaps you need to compare the data with the current profile?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question