magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Can not checkout in m2.4.3 when address has extension attribute

Open MaiDucQuan97 opened this issue 4 years ago • 23 comments

Preconditions (*)

  1. 2.4.3-p1

Steps to reproduce (*)

  1. Address have extension attribute
  2. Already reproduce this issue in default m2.4.3

Expected result (*)

  1. Checkout success

Actual result (*)

  1. Can not checkout
  2. Error message: Object of class Magento\Quote\Api\Data\AddressExtension could not be converted to string Selection_510 Selection_513

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • [x] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

MaiDucQuan97 avatar Sep 30 '21 04:09 MaiDucQuan97

Hi @MaiDucQuan97. Thank you for your report. To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar Sep 30 '21 04:09 m2-assistant[bot]

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Sep 30 '21 06:09 m2-assistant[bot]

Hi every body, I also got this error when I try to checkout with guest customer ( order customer that don't have any address before access checkout page ) Magento 2.4.3 have added the function to compare shipping and billing address when order is place. Checkout Process working fine if I don't make any customize.

But when I add extension_attribute to AddressInterface, the function array_diff() will cause an error because $billingData and $shippingData contain an object. class: Magento\CheckoutStaging\Plugin\GuestPaymentInformationManagementPlugin Magento\CheckoutStaging\Plugin\PaymentInformationManagementPlugin

image

Can you fix it asap? thank you

ducquywp92 avatar Sep 30 '21 07:09 ducquywp92

Is this EE version only?

pemann avatar Oct 07 '21 13:10 pemann

I have also faced this issue on Magento EE 2.4.3. It seems to affect sites that have the CheckoutStaging module enabled (which is the default) and who are using custom extension attributes for addresses. Custom extension attributes for addresses are documented at https://devdocs.magento.com/guides/v2.4/howdoi/checkout/checkout_new_field.html, and so should be something Magento fully supports.

For anyone else facing this issue, the following patch has been working well for us (placed in the m2-hotfixes directory on cloud installations):

--- a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
@@ -101,7 +101,7 @@
         $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);

--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@
                 $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);

braders avatar Nov 09 '21 09:11 braders

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Nov 09 '21 13:11 m2-assistant[bot]

Hi @dborishansky. Thank you for your request. I'm working on Magento instance for you.

Hi @dborishansky, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@magento give me 2.4-develop instance

dborishansky avatar Jan 06 '22 17:01 dborishansky

Hi @dborishansky. Thank you for your request. I'm working on Magento instance for you.

Hi @dborishansky, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

Hi @MaiDucQuan97,

Thank you for reporting the issue. However, we tried to reproduce it on Magento 2.4-develop but the address extension functionality works as expected. Steps followed to reproduce issue:

  1. Added a new plugin and added the address extension attribute by following the steps given in the doc.

  2. Verified the checkout functionality after adding the address extension attribute as a Guest user as well as the registered user.

  3. Checkout functionality works as expected and I was able to place the order. (See the attached screenshots.) Screenshot 2021-11-10 at 8 18 39 PM Screenshot 2021-11-10 at 8 21 52 PM Screenshot 2021-11-10 at 8 22 49 PM

  4. We tested the address attribute extension for string and array type and it works as expected.

If the issue still persists at your end then provide the issue details in depth also provide screenshots or video, accordingly I’ll try to reproduce it again.

Thanks

engcom-Hotel avatar Jan 12 '22 09:01 engcom-Hotel

@engcom-Hotel

The issue happens in the module CheckoutStaging (as pointed by @braders) when you send extension_attributes as part of Billiing Address (screen 1), OR when shipping address contains extension attributes when order is placed (screen 2).

Screen 1 image

Screen 2 image

wsbrs avatar Jan 21 '22 12:01 wsbrs

We have same issue in Magento EE 2.4.3 For us only works if we remove "extension_attributes" key from both (billingData, shippingData)

$removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$shippingData = array_diff_key($shippingData, array_flip($removeKeys));

igi8819 avatar Feb 04 '22 12:02 igi8819

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Feb 09 '22 06:02 m2-assistant[bot]

Hi @MaiDucQuan97, Thank you for reporting the issue.

I tried reproducing the issue on Magento 2.4-develop branch EE edition and I was able to reproduce the issue.

Steps followed to reproduce the issue:-

  1. Install fresh Magento 2.4-develop instance EE edition

  2. Add Extension attributes for Magento\Quote\Api\Data\AddressInterface Screenshot 2022-02-11 at 4 03 46 AM

  3. Override LayoutProcessor and all other required mixins by following the official documentation

  4. Try to place order from Frontend through Guest Checkout image

Note: I have added unit_number in shipping data

Expected Result: User should be able to checkout successfully

Actual Result:

  1. Can not checkout
  2. Error message: Object of class Magento\Quote\Api\Data\AddressExtension could not be converted to string Screenshot 2022-02-11 at 4 11 48 AM

Hence confirming the issue.

Thanks!

engcom-Lima avatar Feb 10 '22 22:02 engcom-Lima

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-2376 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Feb 10 '22 22:02 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Feb 10 '22 22:02 m2-assistant[bot]

Also facing this issue in 2.4.4. It would be possible to add a check for AbstractSimpleObject and then cast it to array and json_encode it:

private function convertAddressValueToFlatArray(array $address): array
    {
        array_walk(
            $address,
            function (&$value) {
                if (is_array($value) && isset($value['value'])) {
                    if (!is_array($value['value'])) {
                        $value = (string)$value['value'];
                    } elseif (isset($value['value'][0]['file'])) {
                        $value = $value['value'][0]['file'];
                    }
                } else {
                    if ($value instanceof AbstractSimpleObject) {
                        $value = json_encode((array) $value);
                    }
                }
            }
        );
        return $address;
    }

This way the extension attribute is converted to a string, and the values are still being compared.

MrBlueEyez avatar Apr 21 '22 09:04 MrBlueEyez

@magento i'm working on it

Pranav-242 avatar May 31 '22 06:05 Pranav-242

Hi folks, any update on this ticket?

tuyennn avatar Jul 21 '22 10:07 tuyennn

Hi All, any updates about the solution? It still happens :)

vpodorozh avatar Aug 23 '22 06:08 vpodorozh

Just discovered this issue on 2.4.4 EE, does @braders patch still work as a temporary fix? Is this still a thing on 2.4.5?

frostitution avatar Sep 19 '22 21:09 frostitution

Internal Team started working on this issue and solution is almost ready

chittima avatar Oct 13 '22 14:10 chittima

A patch for you guys while waiting for updating from Magento. https://gist.github.com/trunglv/9956b6e4adb206ad304c0b00eec05a5a

trunglv avatar Nov 07 '22 16:11 trunglv

Issue is already fixed in the develop branch and not reproducible anymore. Here is the commit https://github.com/magento-commerce/magento2ce/commit/b4f87e9632055d369a0a4c943dee00888c336ea4

chittima avatar Nov 07 '22 16:11 chittima

Thanks for the update @chittima. We are closing this issue.

Thanks

engcom-Hotel avatar Nov 09 '22 08:11 engcom-Hotel

Hi, @chittima I am facing the same issue on Magento 2.4.3P with guest users only and I check your commit link its shows 404 can you please share the patch with me?

Thanks

mhamzaraja avatar Nov 17 '22 08:11 mhamzaraja

Hi @mhamzaraja Please find the commit: b4f87e9632055d369a0a4c943dee00888c336ea4

chittima avatar Nov 17 '22 15:11 chittima