Created
November 9, 2020 11:44
-
-
Save Padilo300/98102c0e33c6ecc21667cb75f7067c68 to your computer and use it in GitHub Desktop.
БУС обработка заказа
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddEventHandler('sale', 'OnOrderAdd', "bx24AddDeal"); | |
function bx24AddDeal($orderID, &$arFields){ | |
$arOrder = CSaleOrder::GetByID($orderID); | |
//-- получаем телефоны и адрес | |
$order_props = CSaleOrderPropsValue::GetOrderProps($orderID); | |
$phone=""; | |
$index = ""; | |
$country_name = ""; | |
$city_name = ""; | |
$address = ""; | |
while ($arProps = $order_props->Fetch()) | |
{ | |
if ($arProps["CODE"] == "PHONE") | |
{ | |
$phone = htmlspecialchars($arProps["VALUE"]); | |
} | |
if ($arProps["CODE"] == "LOCATION") | |
{ | |
$arLocs = CSaleLocation::GetByID($arProps["VALUE"]); | |
$country_name = $arLocs["COUNTRY_NAME_ORIG"]; | |
$city_name = $arLocs["CITY_NAME_ORIG"]; | |
} | |
if ($arProps["CODE"] == "INDEX") | |
{ | |
$index = $arProps["VALUE"]; | |
} | |
if ($arProps["CODE"] == "ADDRESS") | |
{ | |
$address = $arProps["VALUE"]; | |
} | |
} | |
$full_address = $index.", ".$country_name."-".$city_name.", ".$address; | |
//-- получаем название службы доставки | |
$arDeliv = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"]); | |
$delivery_name = ""; | |
if ($arDeliv) | |
{ | |
$delivery_name = $arDeliv["NAME"]; | |
} | |
//-- получаем название платежной системы | |
$arPaySystem = CSalePaySystem::GetByID($arOrder["PAY_SYSTEM_ID"]); | |
$pay_system_name = ""; | |
if ($arPaySystem) | |
{ | |
$pay_system_name = $arPaySystem["NAME"]; | |
} | |
//-- добавляем новые поля в массив результатов | |
$arFields["ORDER_DESCRIPTION"] = $arOrder["USER_DESCRIPTION"]; | |
$arFields["PHONE"] = $phone; | |
$arFields["DELIVERY_NAME"] = $delivery_name; | |
$arFields["PAYSYSTEM"] = $pay_system_name; | |
$arFields["FULL_ADDRESS"] = $full_address; | |
$arFields["utm_term"] = $_COOKIE['utm_term'] ; | |
$arFields["utm_source"] = $_COOKIE['utm_source'] ; | |
$arFields["utm_medium"] = $_COOKIE['utm_medium'] ; | |
$arFields["utm_content"] = $_COOKIE['utm_content'] ; | |
$arFields["utm_campaign"] = $_COOKIE['utm_campaign'] ; | |
$ch = curl_init('https://1.padilo.pro/add_deal.php'); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, ['deal' => json_encode($arFields)]); | |
curl_exec($ch); | |
curl_close($ch); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment