From 6122e967aa2af19c4253bd02c9fc0a3923266f99 Mon Sep 17 00:00:00 2001 From: Matthijs Iriks Date: Thu, 29 Jun 2023 17:42:02 +0200 Subject: [PATCH] Update PaymentInformationManagement.php Added a check in the beforeSave function, this will break if the user doesnt have an default address in their profile... for whatever reason? anyway... :) Here you go! --- .../Model/PaymentInformationManagement.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Plugin/Magento/Checkout/Model/PaymentInformationManagement.php b/Plugin/Magento/Checkout/Model/PaymentInformationManagement.php index b8612ae..a658d8e 100644 --- a/Plugin/Magento/Checkout/Model/PaymentInformationManagement.php +++ b/Plugin/Magento/Checkout/Model/PaymentInformationManagement.php @@ -25,7 +25,8 @@ class PaymentInformationManagement */ public function __construct( Data $helper - ) { + ) + { $this->helper = $helper; } @@ -38,17 +39,20 @@ public function __construct( */ public function beforeSavePaymentInformation( \Magento\Checkout\Model\PaymentInformationManagement $subject, - $cartId, - PaymentInterface $paymentMethod, - AddressInterface $address - ) { - $extAttributes = $address->getExtensionAttributes(); - if (!empty($extAttributes)) { - $this->helper->transportFieldsFromExtensionAttributesToObject( - $extAttributes, - $address, - 'extra_checkout_billing_address_fields' - ); + $cartId, + PaymentInterface $paymentMethod, + AddressInterface $address = null + ) + { + if ($address) { + $extAttributes = $address->getExtensionAttributes(); + if (!empty($extAttributes)) { + $this->helper->transportFieldsFromExtensionAttributesToObject( + $extAttributes, + $address, + 'extra_checkout_billing_address_fields' + ); + } } } }