mr.rifa
6/20/2018 - 1:49 PM

Событие отправки письма при Заказе

Добавляем список товаров пользователя. И добавляем в шаблон письма

AddEventHandler("sale", "OnOrderNewSendEmail", Array("PESCMARKETSendEmail", "OnAfterOrderPaid"));
class PESCMARKETSendEmail {
    function OnAfterOrderPaid($orderID, &$eventName, &$arFields){
        $order_arr = CSaleOrder::GetByID($orderID);

        $basket_arr = CSaleBasket::GetList(array(),array("ORDER_ID"=>$orderID),false,false,array("*"));
        $arFields['ORDER_LIST_TABLE'] = "";
        $IBLOCK_PRODUCT_ID = 1;
        while ($arItems = $basket_arr->Fetch()) {
            $INSTALL_VALUE = "";
            $arInfo = CCatalogSKU::GetInfoByProductIBlock($IBLOCK_PRODUCT_ID);

            if (is_array($arInfo)) {
                $rsOffers = CIBlockElement::GetList(array(),array('IBLOCK_ID' => $arInfo['IBLOCK_ID'], 'ID' => $arItems['PRODUCT_ID']), false, false,array("PROPERTY_INSTALL"));
                while ($arOffer = $rsOffers->GetNext()) {
                    $INSTALL_VALUE = $arOffer['PROPERTY_INSTALL_VALUE'];
                }
            }

            $out = '
            <tr style="background: #f9f9f9">
                <td style="font-size: 14px; color: rgb(0, 0, 0); line-height: 1.5; text-align: left; padding: 15px;">
                    '.$arItems['NAME'].'
                </td>
                <td style="font-size: 14px; color: rgb(0, 0, 0); line-height: 1.5; text-align: center; padding: 15px; ">
                    '.number_format( $arItems['QUANTITY'], 0 ,",", " " ).' шт.
                </td>
                <td style="font-size: 14px; color: rgb(0, 0, 0); line-height: 1.5; text-align: center; padding: 15px; ">
                    '.$INSTALL_VALUE.'
                </td>
                <td style="font-size: 14px; color: rgb(0, 0, 0); line-height: 1.5; text-align: left; padding: 15px;">
                    '.number_format( $arItems['PRICE'], 0 ,",", " " ) .' р.
                </td>
            </tr>';

            $arFields['ORDER_LIST_TABLE'] .= $out;
        }
    }
}