init
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\CustomerVat\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Quote\Model\Quote;
|
||||
use Magento\Sales\Model\Order;
|
||||
|
||||
class CopyVatContextToOrder implements ObserverInterface
|
||||
{
|
||||
private const FIELDS = ['esun_vat_id', 'esun_vat_number', 'esun_vat_country_id',
|
||||
'esun_vat_company_name', 'esun_vat_exempt', 'esun_nominal_tax_rate', 'esun_tax_mode'];
|
||||
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
$quote = $observer->getEvent()->getQuote();
|
||||
$order = $observer->getEvent()->getOrder();
|
||||
if (!$quote instanceof Quote || !$order instanceof Order) {
|
||||
return;
|
||||
}
|
||||
foreach (self::FIELDS as $field) {
|
||||
$order->setData($field, $quote->getData($field));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user