E
E
Eugene M2018-12-24 19:58:57
1C-Bitrix
Eugene M, 2018-12-24 19:58:57

How to display user id in Bitrix email template?

The phone displays, but there is no user id, what is the error?
[SALE_NEW_ORDER]
in /bitrix/php_interface/init.php

//-- Добавление обработчика события

AddEventHandler("sale", "OnOrderNewSendEmail", "bxModifySaleMails");

//-- Обработчик события

function bxModifySaleMails($orderID, &$eventName, &$arFields)
{
  $arOrder = CSaleOrder::GetByID($orderID);
  
  //-- получаем телефон и id пользователя
  $order_props = CSaleOrderPropsValue::GetOrderProps($orderID);
  $phone="";
  $user_id="";
  while ($arProps = $order_props->Fetch())
  {
    if ($arProps["CODE"] == "PHONE")
    {
       $phone = htmlspecialchars($arProps["VALUE"]);
    }
   if ($arProps["CODE"] == "USER_ID")
    {
       $user_id = htmlspecialchars($arProps["VALUE"]);
    }
  }


  //-- добавляем новые поля в массив результатов
  $arFields["PHONE"] = $phone;
  $arFields["USER_ID"] = $user_id;
 
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2018-12-25
@hotwind

Because USER_ID is not a property of the order, but one of its fields.
$user_id = $arOrder["USER_ID"];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question