пример init.php
Код |
---|
<? //СОБЫТИЕ AddEventHandler("sale", "OnOrderNewSendEmail", "ModifyOrderSaleMails"); function ModifyOrderSaleMails($orderID, &$eventName, &$arFields) { if(CModule::IncludeModule("sale") && CModule::IncludeModule("iblock")) { //СОСТАВ ЗАКАЗА РАЗБИРАЕМ SALE_ORDER НА ЗАПЧАСТИ $strOrderList = ""; $dbBasketItems = CSaleBasket::GetList( array("NAME" => "ASC"), array("ORDER_ID" => $orderID), false, false, array("PRODUCT_ID", "ID", "NAME", "QUANTITY", "PRICE", "CURRENCY") ); while ($arProps = $dbBasketItems->Fetch()) { //ДРОБИМ НА ЗАПЧАСТИ $name = $arProps['NAME']; $quantity = $arProps['QUANTITY']; $price = $arProps['PRICE']; $currency = $arProps['CURRENCY']; $summ = $arProps['QUANTITY'] * $arProps['PRICE']; } //ОБЪЯВЛЯЕМ НОВЫЕ ПЕРМЕННЫЕ ДЛЯ ПИСЬМА $arFields["NAME_ITEM"] = $name; $arFields["QUANTITY_ITEM"] = $quantity; $arFields["PRICE_ITEM"] = $price; $arFields["CURRENCY_ITEM"] = $currency; $arFields["SUMM_ITEM"] = $summ; } } //-- Добавление обработчика события 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"] == "INDEX") { $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; } ?> |