We have upgraded Magento version from 2.3.5p2 to 2.4.3 P1. After that while placing an order we are getting issue. Error:
Object of class Magento\Quote\Api\Data\AddressExtension could not be converted to string in vendor\magento\module-checkout-staging\Plugin\GuestPaymentInformationManagementPlugin.php:106
We observed issue with extension attribute below is the code
<extension_attributes for="Magento\Quote\Api\Data\AddressInterface">
<attribute code="tm_address_id" type="string" />
How can the error be resolved?
I got to this same issue today and the problem happens at vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
The bug here is that the extension attribute can not be converted to a string when comparing shipping address and billing address.
In my case, the extension attribute is only added to billing address and won't matter in the shipping vs billing address comparison.
This seems to be an unexpected case not covered by Adobe/Magento team.
I was not able to find any official patches fixing this, so I created this one that just removes the extension_attributes key from $billingData before it compares with shipping data.
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
EDIT:
Same bug happens to guest at vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
Same solution, single patch for both:
diff --git a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
index 2728b160..ee8afacd 100644
--- a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
@@ -101,7 +101,7 @@ class GuestPaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddress->getData());
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData,$shippingData);
return empty($difference);
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
I got to this same issue today and the problem happens at vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
The bug here is that the extension attribute can not be converted to a string when comparing shipping address and billing address.
In my case, the extension attribute is only added to billing address and won't matter in the shipping vs billing address comparison.
This seems to be an unexpected case not covered by Adobe/Magento team.
I was not able to find any official patches fixing this, so I created this one that just removes the extension_attributes key from $billingData before it compares with shipping data.
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
EDIT:
Same bug happens to guest at vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
Same solution, single patch for both:
diff --git a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
index 2728b160..ee8afacd 100644
--- a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
@@ -101,7 +101,7 @@ class GuestPaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddress->getData());
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData,$shippingData);
return empty($difference);
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With