403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/delivery/services/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/delivery/services/recipientdataprovider.php
<?php

namespace Bitrix\Sale\Delivery\Services;

use Bitrix\Main\Event;
use Bitrix\Main\EventResult;
use Bitrix\Sale\EventActions;
use Bitrix\Sale\Order;
use Bitrix\Sale\Shipment;

/**
 * Class RecipientDataProvider
 * @package Bitrix\Sale\Delivery\Services
 * @internal
 */
final class RecipientDataProvider
{
	/**
	 * @param Shipment $shipment
	 * @return Contact|null
	 */
	public static function getContact(Shipment $shipment): ?Contact
	{
		$event = new Event(
			'sale',
			EventActions::EVENT_ON_NEED_DELIVERY_RECIPIENT_CONTACT,
			['SHIPMENT' => $shipment]
		);

		$event->send();
		$eventResults = $event->getResults();
		foreach ($eventResults as $eventResult)
		{
			if ($eventResult->getType() === EventResult::SUCCESS)
			{
				$recipientContact = $eventResult->getParameters();
				if ($recipientContact instanceof Contact)
				{
					return $recipientContact;
				}
			}
		}

		$order = $shipment->getOrder();
		if (!$order)
		{
			return null;
		}

		return self::getContactFromOrder($order);
	}

	/**
	 * @param Order $order
	 * @return Contact|null
	 */
	private static function getContactFromOrder(Order $order): ?Contact
	{
		$contact = new Contact();

		$buyerName = $order->getPropertyCollection()->getAttribute('IS_PAYER');
		if ($buyerName)
		{
			$contact->setName((string)$buyerName->getValue());
		}

		$buyerPhone = $order->getPropertyCollection()->getAttribute('IS_PHONE');
		if ($buyerPhone)
		{
			$contact->addPhone(new Phone('OTHER', (string)$buyerPhone->getValue()));
		}

		return $contact;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit