Rus
Eng
Перехват отправки письма при оформлении заказа в Битрикс
Order site
By contacting me you will receive a reliable and knowledgeable contractor who will quickly and efficiently implement any task for you and your business.

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;
}
    }
}  

Comments

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

Send

FEEDBACK

Email me

Please message me to discuss the task. I work remotely and officially (as a self-employed professional); my hourly rate is 1,800 RUB, and I can dedicate 3–4 hours a day to the project. I respond quickly, and the consultation is free.

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

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

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

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