Interception of sending a letter when placing an order in Bitrix
Перехват отправки письма при оформлении заказа в Битрикс

All English-language materials have been translated fully automatically using the Google service

Often, I am tasked with adding or updating data sent by the sale.order.ajax component by a letter to a client when a new order is formed.

  AddEventHandler ("sale", "OnOrderNewSendEmail", Array ("OnOrderNewSendEmailClass", "OnOrderNewSendEmailModify"));
class OnOrderNewSendEmailClass
    function OnOrderNewSendEmailModify ($ orderID, & $ eventName, & $ arFields)
if (CModule :: IncludeModule ("sale") && CModule :: IncludeModule ("iblock"))
// Add new data to the email template variable
$ arFields ["SOME_ADDITIONAL_VARIABLE"] = $ newData;

// You can work with order data using the $ orderID variable
// For example, you can get the contents of the basket and display the names of the finished products in a letter to the user
$ items = CSaleBasket :: GetList (array ("NAME" => "DESC"), array ("ORDER_ID" => $ orderID), false, false, array ("*"));
$ temp = '';

while ($ item = $ items-> Fetch ()) {
$ temp. = 'Name:'. $ item ['NAME']. ' ('. $ item [' QUANTITY '].') / r / n / ';

// Fill in new variables with the name and quantity of the product
$ arFields ["ORDER_ITEMS"] = $ temp;

// You can also get the composition of the order and post it to the variables of the mail template
// $ order = CSaleOrder :: GetByID ($ orderID); // Getting the order content
$ props = CSaleOrderPropsValue :: GetOrderProps ($ orderID); // Get order properties

// You can view the property ID in the store settings, on the "Property List" page
// This page is located at Store -> Settings -> Order properties -> List of properties
$ temp = '';
while ($ prop = $ props-> Fetch ()) {
if ($ prop ['ORDER_PROPS_ID'] == $ id) {// where $ id is the id of the property on the specified page
$ temp. = 'New property:'. $ prop ['VALUE'];
$ arFields ["ORDER_PROPS"] = $ temp;


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96



Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number