M
M
Michael2018-01-29 20:42:38
1C-Bitrix
Michael, 2018-01-29 20:42:38

Why is the composition of the order bitrix not coming?

Good afternoon, dear experts! I'm a newbie, don't kick me too hard.
Order contents are not received in the mail, although there is #ORDER_LIST# in the mail templates.
Rummaged for half an hour and came across a file in my www/ajax/order/add.php

<?php
define('STOP_STATISTICS', true);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');


CModule::IncludeModule('catalog');
CModule::IncludeModule('sale');


//регистрация пользователя
if ($USER->IsAuthorized()){
  $user = $USER->GetID();
}
else{
  $pass = crc32(time());
  $USER->Register($_REQUEST['email'], $_REQUEST['name'], "", $pass, $pass, $_REQUEST['email']);
  $user = $USER->GetID();
  $USER->Authorize($user);
  
  CEvent::Send("NEWREG", SITE_ID, array(
    "EMAIL" => $_REQUEST['email'],
    "LOGIN" => $_REQUEST['email'],
    "PASSWORD" => $pass,
  ));
}

//Получение корзины
$fuser = CSaleBasket::GetBasketUserID();
$dbBaket = CSaleBasket::GetList(
   array("NAME" => "ASC"),
   array("FUSER_ID" => $fuser, "LID" => SITE_ID, "ORDER_ID" => "NULL")
);
$arItems = array();
while ($arBasket = $dbBaket->GetNext()){

   if ($arBasket["DELAY"]=="N" && $arBasket["CAN_BUY"]=="Y")
   {
    $arBasket["PRICE_FORMATED"] = SaleFormatCurrency($arBasket["PRICE"], $arBasket["CURRENCY"]);
    $tmp[$arBasket["ID"]] = $arBasket;
   }            
}

//Стоимость заказа
if (!empty($tmp) && CModule::IncludeModule("currency"))
{
   $baseCurrency = CCurrency::GetBaseCurrency();

   foreach ($tmp as $arBasketItem)
   {

    if ($arBasketItem["CURRENCY"] != $baseCurrency)
     $arBasket["PRICE"] = CCurrencyRates::ConvertCurrency($arBasketItem["PRICE"], $arBasketItem["CURRENCY"], $baseCurrency);

    if ($arBasketItem["DISCOUNT_PRICE"] > 0)
     $totalSumDiscount += $arBasketItem["QUANTITY"] * $arBasketItem["DISCOUNT_PRICE"];
    else
     $totalSumDiscount += $arBasketItem["QUANTITY"] * $arBasketItem["PRICE"];
   }
}


//Создание заказа
$arFields = array(
  "LID" => SITE_ID,
  "PERSON_TYPE_ID" => 1,
  "PAYED" => "N",
  "CANCELED" => "N",
  "STATUS_ID" => "N",
  "PRICE" => $totalSumDiscount,
  "CURRENCY" => "RUB",
  "USER_ID" => $user,
  "PAY_SYSTEM_ID" => 1,
  "DELIVERY_ID" => 1,
  "USER_DESCRIPTION" => $_REQUEST['comment']
);

$id = CSaleOrder::Add($arFields);
CSaleBasket::OrderBasket($id, $fuser, SITE_ID);

//свойства заказа
$props = [
  '1' => 'name',
  '2' => 'company',
  '3' => 'phone',
  '4' => 'email',
  '5' => 'address',
];

for ($i = 1; $i < 6; $i++){
  $arFields = array(
    "ORDER_ID" => $id,
    "NAME" => 'Имя',
    "ORDER_PROPS_ID" => $i,
    "VALUE" => $_REQUEST[$props[$i]]
  );
  CSaleOrderPropsValue::Add($arFields);
}

//E-mail для оповещений
$res = CSite::GetList($by="sort", $order="desc", array('ACTIVE'=>'Y'));
if($arSite = $res->Fetch()){
  $defaultEmail = $arSite['EMAIL'];
}

//оповещения для покупателя
CEvent::Send("SALE_NEW_ORDER", SITE_ID, array(
  "ORDER_ID" => $id,
  "ORDER_DATE" => FormatDate('j F Y', time()),
  "ORDER_USER" => htmlspecialchars($_REQUEST['name']),
  "PRICE" => $totalSumDiscount,
  "EMAIL" => $_REQUEST['email'],
  "SALE_EMAIL" => $defaultEmail,
  "SITE_NAME" => '',
  "SERVER_NAME" => '',
));


//оповещения для администрации
CEvent::Send("NEWORDER", SITE_ID, array(
  "ORDER_ID" => $id,
  "ORDER_DATE" => FormatDate('j F Y', time()),
  "NAME" => htmlspecialchars($_REQUEST['name']),
  "COMPANY" => htmlspecialchars($_REQUEST['company']),
  "PRICE" => $totalSumDiscount,
  "EMAIL" => $_REQUEST['email'],
  "SALE_EMAIL" => $defaultEmail,
  "PHONE" => htmlspecialchars($_REQUEST['phone']),
  "ADDRESS" => htmlspecialchars($_REQUEST['address']),
  "COMMENT" => htmlspecialchars($_REQUEST['comment']),
));

?>

Mail template:
User left a new order on the site
Order number: #ORDER_ID#
Date: #ORDER_DATE#
Name: #NAME#
Company: #COMPANY#
Phone: #PHONE#
E-mail: #EMAIL#
Address: #ADDRESS#
Comment: # COMMENT#
Order contents: #ORDER_LIST#
As I understand it, all fields of mail templates are taken from it. The question is how to change the file so that the composition of the order comes?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Mifle, 2018-01-30
@OlegMifle

What did not please the standard component?
You need to pass the #ORDER_LIST# key with the html value of the goods list table in the order to the 3rd parameter of CEvent::Send.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question