L
L
lord amotar2016-01-20 09:46:36
1C-Bitrix
lord amotar, 2016-01-20 09:46:36

How to add new mail template fields?

Good afternoon
, there are fields in the new order email template, you need to change the fields:
#ORDER_LIST# - order
contents #USER_DATA# - customer information
field #ORDER_LIST# displays everything in one line (product code, product name, product quantity, product price)
#USER_DATA field # displays everything in one line (full name, city, address, phone)
I want everything to be displayed separately
, for example
#USER_DATA# - full name
#USER_City# - City
#USER_Street # - Street
#USER_Phone# - Phone
, etc. d.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Neverov, 2016-01-20
@deMone

In fact, adding it on its own will not lead to anything, because the set of variables is passed by the kernel source code to the template.
Accordingly, if the source code does not pass the variables you need, they will not appear in the template.
To solve the problem, you need to disable the automatic sending of the letter, then write your own ordering event handler, in which you manually call the sending of the template, which will pass all the fields you need.
In short, you cannot do without a programmer.
If you need to do it - I can help, write.

S
Sergey, 2016-01-20
@gangstarcj

Must be added to init.php

<?
AddEventHandler("main", "OnBeforeEventAdd", array("MailPost", "OnBeforeEventAddHandler"));
class MailPost
{
    function OnBeforeEventAddHandler(&$event, &$lid, &$arFields)
    {
    if ($event=="SALE_NEW_ORDER") {
      $order = CSaleOrder::GetByID($arFields['ORDER_ID']);
    
     if(CModule::IncludeModule('sale')) {

     	if ($arOrder = CSaleOrder::GetByID($arFields['ORDER_ID'])) {
     		
     		if ($arPaySys = CSalePaySystem::GetByID($arOrder["PAY_SYSTEM_ID"]))
          {
            if ($arPaySys["ID"] == "5") {
              $arFields["REKVIZIT_SBERBANK"] = "<br>Номер карты сбербанка 4276720010044925 <br>Ирина Александровна С <br>В комментарии к оплате укажите вашу фамилию.";	
            }
             $arFields["PAY_SYSTEM_ID"] = $arPaySys["NAME"];
          }

        if ($arDeliv = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"]))
        {
           $arFields["DELIVERY_ID"] = $arDeliv["NAME"];
        }
        if ($arOrder["DELIVERY_ID"] == "pickpoint:postamat") {
              $arFields["DELIVERY_ID"] = "Pickpoint";
            }

      }
      if ($arOrderPropsValue = CSaleOrderPropsValue::GetOrderProps($arFields['ORDER_ID'])) {
          while ($orderProp = $arOrderPropsValue->Fetch()) {
            $orderProp["ORDER_PROPS_ID"] = intval($orderProp["ORDER_PROPS_ID"]);
            switch ($orderProp["ORDER_PROPS_ID"]) {
              case 1:
                $arFields["FIO"] = $orderProp["VALUE"];
                break;
              case 9:
                $arFields["LASTNAME"] = $orderProp["VALUE"];
                break;
              case 10:
                $arFields["FIRSTNAME"] = $orderProp["VALUE"];
                break;
              case 11:
                $arFields["SECONDNAME"] = $orderProp["VALUE"];
                break;
              case 3:
                $arFields["PHONE"] = $orderProp["VALUE"];
                break;
              case 8:
                $arFields["INDEX"] = $orderProp["VALUE"];
                break;	
              case 5:
                $arLocs = CSaleLocation::GetByID($orderProp["VALUE"], LANGUAGE_ID);
                $arFields["LOCATION"] = $arLocs["COUNTRY_NAME"].' / '.$arLocs["REGION_NAME"].' / '.$arLocs["CITY_NAME_ORIG"];
                break;
              case 7:
                $arFields["ADDRESS"] = $orderProp["VALUE"];
                break;
            }
            $arFields["FIO"] = $arFields["LASTNAME"]." ".$arFields["FIRSTNAME"]." ".$arFields["SECONDNAME"];

        }
        
      }	

       }
    }
        
    }
}

?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question