Plugin/AddtionalCustomerData.php
<?php
/**
* PagBank Payment Magento Module.
*
* Copyright © 2023 PagBank. All rights reserved.
*
* @author Bruno Elisei <brunoelisei@o2ti.com>
* @license See LICENSE for license details.
*/
namespace PagBank\PaymentMagento\Plugin;
use Magento\Customer\CustomerData\Customer;
use Magento\Customer\Helper\Session\CurrentCustomer;
/**
* Class Addtional Customer Data - Insert Addtional Data in Customer.
*/
class AddtionalCustomerData
{
/**
* @var CurrentCustomer
*/
protected $currentCustomer;
/**
* @param CurrentCustomer $currentCustomer
*/
public function __construct(
CurrentCustomer $currentCustomer
) {
$this->currentCustomer = $currentCustomer;
}
/**
* Add Session Data.
*
* @param Customer $subject
* @param array $result
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetSectionData(Customer $subject, array $result): array
{
if ($this->currentCustomer->getCustomerId()) {
$customer = $this->currentCustomer->getCustomer();
$result['taxvat'] = ($customer->getTaxVat()) ?: null;
}
return $result;
}
}