Created
August 4, 2020 13:00
-
-
Save Ginnw2/728ece3552e45ff5848333c254b64e3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddEventHandler("sale", "OnOrderNewSendEmail", "bxModifySaleMails"); | |
//-- Собственно обработчик события | |
function bxModifySaleMails($orderID, &$eventName, &$arFields) | |
{ | |
$arOrder = CSaleOrder::GetByID($orderID); | |
//-- получаем телефоны и адрес | |
$order_props = CSaleOrderPropsValue::GetOrderProps($orderID); | |
$phone=""; | |
$index = ""; | |
$country_name = ""; | |
$city_name = ""; | |
$address = ""; | |
while ($arProps = $order_props->Fetch()) | |
{ | |
if ($arProps["CODE"] == "PHONE") | |
{ | |
$phone = htmlspecialchars($arProps["VALUE"]); | |
} | |
if ($arProps["CODE"] == "LOCATION") | |
{ | |
$arLocs = CSaleLocation::GetByID($arProps["VALUE"]); | |
$country_name = $arLocs["COUNTRY_NAME_ORIG"]; | |
$city_name = $arLocs["CITY_NAME_ORIG"]; | |
} | |
if ($arProps["CODE"] == "ZIP") | |
{ | |
$index = $arProps["VALUE"]; | |
} | |
if ($arProps["CODE"] == "ADDRESS") | |
{ | |
$address = $arProps["VALUE"]; | |
} | |
} | |
$full_address = $index.", ".$country_name.", ".$city_name.", ".$address; | |
//-- получаем название службы доставки | |
$arDeliv = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"]); | |
$delivery_name = ""; | |
if ($arDeliv) | |
{ | |
$delivery_name = $arDeliv["NAME"]; | |
} | |
//-- получаем название платежной системы | |
$arPaySystem = CSalePaySystem::GetByID($arOrder["PAY_SYSTEM_ID"]); | |
$pay_system_name = ""; | |
if ($arPaySystem) | |
{ | |
$pay_system_name = $arPaySystem["NAME"]; | |
} | |
//-- добавляем новые поля в массив результатов | |
$arFields["ORDER_DESCRIPTION"] = $arOrder["USER_DESCRIPTION"]; | |
$arFields["PHONE"] = $phone; | |
$arFields["DELIVERY_NAME"] = $delivery_name; | |
$arFields["PAY_SYSTEM_NAME"] = $pay_system_name; | |
$arFields["FULL_ADDRESS"] = $full_address; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment