|
Bitrix - Событие отправки письма (OnOrderNewSendEmail)
Bitrix - Событие отправки письма (OnOrderNewSendEmail)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?php
//Событие отправки письма AddEventHandler("sale", "OnOrderNewSendEmail", "bxModifySaleMails"); function bxModifySaleMails($orderID, &$eventName, &$arFields) { \Bitrix\Main\Loader::includeModule('sale'); $order = \Bitrix\Sale\Order::load($orderID); $basket = $order->getBasket(); $orderBasket = $basket->getBasketItems(); $DELIVERY_PRICE = $order->getDeliveryPrice(); $ORDER_PRICE = 0; $arOrder = CSaleOrder::GetByID($orderID); if(is_array($arOrder)){ $comment = $arOrder['USER_DESCRIPTION']; } $db_props = CSaleOrderPropsValue::GetOrderProps($orderID);
while ($arProps = $db_props->Fetch()) { $arrOrd[$arProps['CODE']] = $arProps['VALUE']; } $locPropValue = $arrOrd['ZIP']." ".$arrOrd['ADDRESS'];
$arLocs = CSaleLocation::GetByID($arrOrd['LOCATION'], LANGUAGE_ID); $city = $arLocs['CITY_NAME'];
$table = "<table border='1'><thead><tr><th>№</th><th>Товары</th><th>Артикул</th><th>Кол-во</th><th>Цена за шт., руб.</th><th>Итого</th></tr></thead><tbody>"; $i = 1; foreach($orderBasket as $item) { $product_id = $item->getProductId(); $mxResult = CCatalogSku::GetProductInfo($item->getProductId()); if (is_array($mxResult)) $product_id = $mxResult['ID']; $db_props = CIBlockElement::GetProperty(21, $product_id, array(), array("CODE" => "CML2_ARTICLE")); if($ar_props = $db_props->Fetch()) $ARTICLE = $ar_props["VALUE"];
$table .= "<tr>"; $table .= "<td>" . $i . "</td>"; $table .= "<td width='350'>" . str_replace(""", '"', $item->getField('NAME')) . "</td>"; $table .= "<td style='text-align:center'>" . $ARTICLE . "</td>"; $table .= "<td style='text-align:center'>" . $item->getQuantity() . "</td>"; $table .= "<td style='text-align:center'>" . $item->getPrice() . "</td>"; $table .= "<td style='text-align:center'>" . $item->getFinalPrice() . "</td>"; $table .= "</tr>"; $ORDER_PRICE += IntVal($item->getFinalPrice()); $i ++; } error_log('<pre>rsUser'.date('Y/m/d H:i:s')."\n".
print_r($arOrder, true)
.'</pre>' . "\n", 3, $_SERVER['DOCUMENT_ROOT'] . '/new_log_3.log'); $table .= "</tbody></table>"; $arFields["ORDER_LIST"] = $table; $arFields["ORDER_PRICE"] = $ORDER_PRICE; $arFields["DELIVERY_PRICE"] = $DELIVERY_PRICE; $arFields["DELIVERY_CITY"] = $city; $arFields["DELIVERY_ADDRESS"] = $locPropValue; $arFields["DELIVERY_COMMENT"] = $comment; $deliveryIds = $order->getDeliverySystemId(); if(in_array("1", $deliveryIds)) { CEvent::Send("SEWING", "s1", $arFields); return false; } }
?>
|
|