1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
recipientdataprovider.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Delivery\Services;
4
5use Bitrix\Main\Event;
6use Bitrix\Main\EventResult;
7use Bitrix\Sale\EventActions;
8use Bitrix\Sale\Order;
9use Bitrix\Sale\Shipment;
10
17{
22 public static function getContact(Shipment $shipment): ?Contact
23 {
24 $event = new Event(
25 'sale',
27 ['SHIPMENT' => $shipment]
28 );
29
30 $event->send();
31 $eventResults = $event->getResults();
32 foreach ($eventResults as $eventResult)
33 {
34 if ($eventResult->getType() === EventResult::SUCCESS)
35 {
36 $recipientContact = $eventResult->getParameters();
37 if ($recipientContact instanceof Contact)
38 {
39 return $recipientContact;
40 }
41 }
42 }
43
44 $order = $shipment->getOrder();
45 if (!$order)
46 {
47 return null;
48 }
49
50 return self::getContactFromOrder($order);
51 }
52
57 private static function getContactFromOrder(Order $order): ?Contact
58 {
59 $contact = new Contact();
60
61 $buyerName = $order->getPropertyCollection()->getAttribute('IS_PAYER');
62 if ($buyerName)
63 {
64 $contact->setName((string)$buyerName->getValue());
65 }
66
67 $buyerPhone = $order->getPropertyCollection()->getAttribute('IS_PHONE');
68 if ($buyerPhone)
69 {
70 $contact->addPhone(new Phone('OTHER', (string)$buyerPhone->getValue()));
71 }
72
73 return $contact;
74 }
75}
static getContact(Shipment $shipment)
Определения recipientdataprovider.php:22
const EVENT_ON_NEED_DELIVERY_RECIPIENT_CONTACT
Определения eventactions.php:67
getOrder()
Определения shipment.php:1222
Определения buffer.php:3
$order
Определения payment.php:8
$event
Определения prolog_after.php:141
else $buyerName
Определения factura.php:484
$buyerPhone
Определения template.php:85