R
R
redesupar2022-02-16 17:05:52
1C-Bitrix
redesupar, 2022-02-16 17:05:52

How to get the delivery address in Bitrix checkout?

I send an event after placing an order, I need to pull out the delivery address, how can I do this?

I send it like this, but exactly $delValue = urlencode($order->getField('ADDRESS')); does not take

use Bitrix\Main; 
use Bitrix\Sale;
\Bitrix\Main\Loader::includeModule('sale');
Main\EventManager::getInstance()->addEventHandler('sale','OnSaleOrderSaved','OnSaleOrderSavedHandler');
function OnSaleOrderSavedHandler(Main\Event $event) {
    
    $utmCampaign = "";
    $utmContent = "";
    $utmMedium = "";
    $utmSource = "";
    $utmTerm = "";

    if ($_COOKIE["utm_campaign"] != null) {
        $utmCampaign = $_COOKIE["utm_campaign"];
    }
    if ($_COOKIE["utm_content"] != null) {
        $utmContent = $_COOKIE["utm_content"];
    }
    if ($_COOKIE["utm_medium"] != null) {
        $utmMedium = $_COOKIE["utm_medium"];
    }
    if ($_COOKIE["utm_source"] != null) {
        $utmSource = $_COOKIE["utm_source"];
    }
    if ($_COOKIE["utm_term"] != null) {
        $utmTerm = $_COOKIE["utm_term"];
    }

    $orderEntity = $event->getParameter("ENTITY");
    $rsOrder = $orderEntity->getFieldValues();
    $order = Sale\Order::load($rsOrder["ID"]);
    $propertyCollection = $order->getPropertyCollection();
    $arPropertyCollection = $propertyCollection->getArray();
    $namePropValue  = $propertyCollection->getPayerName();
    $emailPropValue  = $propertyCollection->getUserEmail();
    $phonePropValue  = $propertyCollection->getPhone();
    $locPropValue   = $propertyCollection->getDeliveryLocation();
  
    $idValue = urlencode($order->getId());
    $titleValue = urlencode('Новый заказ на сайте eleplace.ru №'.$idValue.'');
    $nameValue = urlencode($namePropValue->getValue());
    $emailValue = urlencode($emailPropValue->getValue());
    $priceValue = urlencode($order->getPrice());
    $phoneValue = urlencode($phonePropValue->getValue());

    $isNew = $event->getParameter("IS_NEW");
$shipmentCollection = $order->getShipmentCollection();

foreach ($shipmentCollection as $shipment) {
$shipmentValue .= '' .$shipment->getDeliveryName();
}
$shipmentValue = urlencode($shipmentValue);
$paymentCollection = $order->getPaymentCollection();

foreach ($paymentCollection as $payment) {
$payValue .= '' .$payment->getPaymentSystemName();
}
$payValue = urlencode($payValue);


    $basket = $order->getBasket();
    $basketItems = $basket->getBasketItems();
    $basketValue = "";
    foreach ($basketItems as $basketItem) {
        $basketValue .= $basketItem->getField('NAME').'-'.$basketItem->getQuantity().'шт.'.' - '.$basketItem->getPrice().' руб.<br />';
    }
    $basketValue = urlencode($basketValue);
    $commentValue = urlencode($order->getField('USER_DESCRIPTION'));
    $delValue = urlencode($order->getField('ADDRESS'));
    if ($isNew) {
        file_get_contents('');
    }
}


if you do $ar = $propertyCollection->getArray(); print_r($ar);
Array
(
    [groups] => Array
        (
            [1] => Array
                (
                    [ID] => 1
                    [PERSON_TYPE_ID] => 1
                    [NAME] => Личные данные
                    [CODE] => 
                    [SORT] => 100
                )

            [2] => Array
                (
                    [ID] => 2
                    [PERSON_TYPE_ID] => 1
                    [NAME] => Данные для доставки
                    [CODE] => 
                    [SORT] => 200
                )

            [5] => Array
                (
                    [ID] => 5
                    [PERSON_TYPE_ID] => 1
                    [NAME] => Skyweb24:Бонусная система
                    [CODE] => 
                    [SORT] => 3
                )

        )

    [properties] => Array
        (
            [0] => Array
                (
                    [ID] => 1
                    [PERSON_TYPE_ID] => 1
                    [NAME] => Ф.И.О.
                    [TYPE] => STRING
                    [REQUIRED] => Y
                    [DEFAULT_VALUE] => 
                    [SORT] => 100
                    [USER_PROPS] => Y
                    [IS_LOCATION] => N
                    [PROPS_GROUP_ID] => 1
                    [DESCRIPTION] => 
                    [IS_EMAIL] => N
                    [IS_PROFILE_NAME] => Y
                    [IS_PAYER] => Y
                    [IS_LOCATION4TAX] => N
                    [IS_FILTERED] => Y
                    [CODE] => FIO
                    [IS_ZIP] => N
                    [IS_PHONE] => N
                    [IS_ADDRESS] => N
                    [IS_ADDRESS_FROM] => N
                    [IS_ADDRESS_TO] => N
                    [ACTIVE] => Y
                    [UTIL] => N
                    [INPUT_FIELD_LOCATION] => 0
                    [MULTIPLE] => N
                    [ENTITY_TYPE] => ORDER
                    [MINLENGTH] => 
                    [MAXLENGTH] => 
                    [PATTERN] => 
                    [MULTILINE] => N
                    [SIZE] => 40
                    [RELATION] => Array
                        (
                        )

                    [VALUE] => Array
                        (
                            [0] => не обрабатывать
                        )

                )

          

            [8] => Array
                (
                    [ID] => 7
                    [PERSON_TYPE_ID] => 1
                    [NAME] => Примечания для службы доставки
                    [TYPE] => STRING
                    [REQUIRED] => Y
                    [DEFAULT_VALUE] => 
                    [SORT] => 150
                    [USER_PROPS] => Y
                    [IS_LOCATION] => N
                    [PROPS_GROUP_ID] => 2
                    [DESCRIPTION] => 
                    [IS_EMAIL] => N
                    [IS_PROFILE_NAME] => N
                    [IS_PAYER] => N
                    [IS_LOCATION4TAX] => N
                    [IS_FILTERED] => N
                    [CODE] => ADDRESS
                    [IS_ZIP] => N
                    [IS_PHONE] => N
                    [IS_ADDRESS] => Y
                    [IS_ADDRESS_FROM] => N
                    [IS_ADDRESS_TO] => N
                    [ACTIVE] => Y
                    [UTIL] => Y
                    [INPUT_FIELD_LOCATION] => 0
                    [MULTIPLE] => N
                    [ENTITY_TYPE] => ORDER
                    [MINLENGTH] => 
                    [MAXLENGTH] => 
                    [PATTERN] => 
                    [MULTILINE] => Y
                    [COLS] => 30
                    [ROWS] => 3
                    [RELATION] => Array
                        (
                        )

                    [VALUE] => Array
                        (
                            [0] => обл Ярославская г Ярославль ул Комсомольская 22
                        )

                )



        )

)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question