Answer the question
In order to leave comments, you need to log in
How to add a text file with order data to a letter with order data sent to a customer?
Actually, the question is in the subject, how to add a text file with order data to the letter with order data sent to the buyer?
I don't know where to drop
Answer the question
In order to leave comments, you need to log in
Mail events allow you to attach files to a letter, but you cannot intervene in the SALE_NEW_ORDER event of sending a letter about a new order. As an option, deactivate the regular mail event SALE_NEW_ORDER, create your own and call it by attaching a file by subscribing to an event in php_interface to create an order, an event from d7 - OnSaleOrderSaved to check the IS_NEW flag. Documentation for it here
Subscribe to the OnBeforeEventAdd event
(taken from a very old working code, cutting out part of the code not for general viewing, but the idea should be clear)
AddEventHandler("main", "OnBeforeEventAdd", array("NewOrderWithPdf", "OnBeforeEventAddHandler"));
class NewOrderWithPdf
{
public function OnBeforeEventAddHandler($event, $lid, $arFields)
{
if ($event == "SALE_NEW_ORDER" && $arFields['ORDER_ID'] > 0) {
$arrMailProps["EVENT_NAME"] = $event;
$arrMailProps["LID"] = $lid;
$arrMailProps["C_FIELDS"] = $arFields;
$arrMailProps['FILE'] = [$pathToFile];
\Bitrix\Main\Mail\Event::send($arrMailProps);
return false;
}
return true;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question