<?
define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt");
AddEventHandler("main", "OnBeforeEventAdd", array("MyClass", "OnBeforeEventAddHandler"));
class MyClass {
function OnBeforeEventAddHandler(&$event, &$lid, &$arFields) {
if($event == "SALE_NEW_ORDER") {
$arOrder = CSaleOrderPropsValue::GetOrderProps($arFields["ORDER_ID"]);
$arOrder_arr = CSaleOrder::GetByID($arFields["ORDER_ID"]);
$arOrder_content = CSaleBasket::GetList(Array(),Array("ORDER_ID"=>$arFields["ORDER_ID"]));
$content = "";
while ($arItems = $arOrder_content->Fetch()){
$content .= '<Элемент_заказа Код_товара="'.$arItems["PRODUCT_XML_ID"].'" Количество="'.$arItems["QUANTITY"].'" Цена="'.$arItems["PRICE"].'" />';
}
$arFields["ORDER_CONTENT"] = $content;
$arFields["ID_CUSTOMER"] = $arOrder_arr["USER_ID"];
$arFields["CODE_CUSTOMER"] = $arOrder_arr["USER_ID"];
$arFields["USER_DESCRIPTION"] = $arOrder_arr["USER_DESCRIPTION"];
while ($arProps = $arOrder->Fetch())
{
if($arProps["CODE"] == "FIO"){
$arFields["ORDER_USER"] = $arProps["VALUE"];
}
if($arProps["CODE"] == "CONTACT_PERSON"){
$arFields["ORDER_USER"] = $arProps["VALUE"];
}
if($arProps["CODE"] == "PHONE"){
$arFields["ORDER_PHONE"] = $arProps["VALUE"];
}
if($arProps["CODE"] == "ZIP"){
$arFields["ORDER_ZIP"] = $arProps["VALUE"];
}
if($arProps["CODE"] == "ADDRESS"){
$arFields["ORDER_ADDRESS"] = $arProps["VALUE"];
}
if($arProps["CODE"] == "LOCATION"){
$arLocs = CSaleLocation::GetByID($arProps["VALUE"]);
$arFields["CITY"] = $arLocs["CITY_NAME"];
$arFields["REGION"] = $arLocs["REGION_NAME"];
$arFields["ORDER_LOCATION"] = $arLocs["REGION_NAME"].", ".$arLocs["CITY_NAME"];
}
}
// Содержимое заказа
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID($val["USER_ID"]),
"LID" => $lid,
"DELAY" => "N",
"CAN_BUY" => "Y",
"ORDER_ID" => $arFields["ORDER_ID"]
),
false,
false,
array()
);
$ordelist = "<table cellpadding='0' cellspacing='0' border='0' width='100%' class='cart_items' style='width:100%;border-spacing:0px;border-color:rgba(0, 0, 0, 0);border-collapse:collapse;border:0px;margin:0 auto;'>";
$ordelist = $ordelist."<tr><td align='left' style='background-color:#fff;padding:3px;border:1px solid #000!important'>Наименование</td><td align='left' style='background-color:#fff;padding:3px;border:1px solid #000!important'>Цена</td><td align='left' style='background-color:#fff;padding:3px;border:1px solid #000!important'>Количество</td><td align='right' style='background-color:#fff;padding:3px;border:1px solid #000!important'>Сумма</td></tr>";
while ($arItem = $dbBasketItems->Fetch())
{
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "PROPERTY_*");
$arFilter = Array("IBLOCK_ID"=>32, 'ID' => $arItem['PRODUCT_ID']);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
$art = '';
while($ob = $res->GetNextElement()) {
//$fields = $ob->GetFields();
$props = $ob->GetProperties();
if(!empty($props['CML2_ARTICLE']['VALUE'])) {
$art = $props['CML2_ARTICLE']['VALUE'];
}
}
$st = (int)$arItem["QUANTITY"]*$arItem["PRICE"];
$quantity = (int)$arItem["QUANTITY"];
$ordelist = $ordelist."<tr><td border='1' align='left' style='padding:3px;border:1px solid #000!important;white-space:nowrap'><b>".$arItem["NAME"]." (арт. ".$art.")</b></td><td border='1' align='left' style='padding:3px;border:1px solid #000!important;white-space:nowrap'>".$arItem["PRICE"]." руб.</td><td border='1' align='center' style='padding:3px;border:1px solid #000!important;white-space:nowrap' style='padding:3px;border:1px solid #000!important;white-space:nowrap'>".$quantity." шт.</td><td border='1' align='right' style='padding:3px;border:1px solid #000!important;white-space:nowrap'>".$st." руб.</td></tr>";
}
$ordelist = $ordelist."</table>";
$arFields["ORDER_LIST"] = $ordelist;
//file_put_contents('/home/bitrix/ext_www/podarki-v-mode.ru/bitrix/php_interface/include/filename.txt', print_r($arFields, true));
// $arFields["ORDER_LIST"] = preg_replace("/\n/i",".00 руб.\n",$arFields["ORDER_LIST"]);
//p($arFields, 1);
//p($arFields, 1);
return $arFields;
}
}
}
<?
AddEventHandler("main", "OnEpilog", "Redirect404");
function Redirect404() {
if(
!defined('ADMIN_SECTION') &&
defined("ERROR_404") &&
defined("PATH_TO_404") &&
file_exists($_SERVER["DOCUMENT_ROOT"].PATH_TO_404)
) {
//LocalRedirect("/404.php", "404 Not Found");
global $APPLICATION;
$APPLICATION->RestartBuffer();
CHTTP::SetStatus("404 Not Found");
include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/header.php");
include($_SERVER["DOCUMENT_ROOT"].PATH_TO_404);
include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/footer.php");
}
}
if(is_file($_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/constants.php')){
include_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/constants.php';
}
if(is_file($_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/functions.php')){
include_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/functions.php';
}
if(is_file($_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/handler.php')){
include_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/php_interface/include/handler.php';
}
Это нормально?
Я с престой раньше не работал не знаю это нормально или нет