magento2-docker/app/code/IpSupply/SyncOrder/Sync/Buyer.php

27 lines
753 B
PHP
Executable File

<?php
namespace IpSupply\SyncOrder\Sync;
class Buyer implements \JsonSerializable
{
public $username = null;
public $fullName = null;
public $primaryPhone = null;
public $email = null;
function __construct(\Magento\Sales\Model\Order $order)
{
$this->username = $order->getCustomerEmail() ?? null;
$this->fullName = $order->getCustomerName() ?? null;
$this->primaryPhone = $order->getBillingAddress()?->getTelephone() ?? $order->getShippingAddress()->getTelephone();
$this->email =
$order->getBillingAddress()?->getEmail()
?? $order->getShippingAddress()->getEmail();
}
public function jsonSerialize(): mixed
{
return get_object_vars($this);
}
}