Last active
July 11, 2018 12:13
-
-
Save madcatgith/089f3011e3a974b0139000e65671440b 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) | |
{ | |
$additional_information = ''; | |
$arOrder = CSaleOrder::GetByID($orderID); | |
$order_props = CSaleOrderPropsValue::GetOrderProps($orderID); | |
$couponList = \Bitrix\Sale\Internals\OrderCouponsTable::getList(array( | |
'select' => array('COUPON','COUPON_ID'), | |
'filter' => array('=ORDER_ID' => $orderID) | |
)); | |
$cp=''; | |
$cp_id=''; | |
$email=''; | |
while ($coupon = $couponList->fetch()) | |
{ | |
$cp = $coupon['COUPON']; | |
$cp_id = $coupon['COUPON_ID']; | |
} | |
while ($arProps = $order_props->Fetch()){ | |
if ($arProps['ORDER_PROPS_ID']==2){ | |
$email='E-mail: '.$arProps['VALUE'].'<br>'; | |
} | |
} | |
if (!empty($cp)&&!empty($cp_id)){ | |
$arFields["COUPON"]=$cp; | |
$arFields["COUPON_ID"]=$cp_id; | |
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); | |
$arEventFields = array( | |
"SITE_NAME" => "OFFICE.by", | |
"DATE" => $arOrder['DATE_INSERT'], | |
"COUPON" => $cp, | |
"COUPON_ID" => $cp_id, | |
"ORDER_ID" => $orderID, | |
"ORDER_NUMBER" => $arOrder["ACCOUNT_NUMBER"], | |
"ORDER_DATE" => $arOrder["DATE_INSERT"], | |
"SALE_EMAIL" => "[email protected]" | |
); | |
if (CModule::IncludeModule("main")): | |
if (CEvent::Send("TICKET_GENERATE_SUPERCOUPON", "s1", $arEventFields)): | |
endif; | |
endif; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment