Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 5 tasks
MaiDucQuan97 opened this issue Sep 30, 2021 · 30 comments
Closed
1 of 5 tasks

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

MaiDucQuan97 opened this issue Sep 30, 2021 · 30 comments
Labels
Area: Cart & Checkout Component: Checkout Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@MaiDucQuan97
Copy link

MaiDucQuan97 commented Sep 30, 2021

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.

  • 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”.
@m2-assistant
Copy link

m2-assistant bot commented Sep 30, 2021

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


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

🕙 You can find the schedule on the Magento Community Calendar page.

📞 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.

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

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

@MaiDucQuan97 MaiDucQuan97 changed the title Can not checkout in m2.4.3 when address have extension attribute Can not checkout in m2.4.3 when address has extension attribute Sep 30, 2021
@engcom-Delta engcom-Delta self-assigned this Sep 30, 2021
@m2-assistant
Copy link

m2-assistant bot commented Sep 30, 2021

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: 👇

  • 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.

@ducquywp92
Copy link

ducquywp92 commented Sep 30, 2021

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

@pemann
Copy link

pemann commented Oct 7, 2021

Is this EE version only?

@engcom-Delta engcom-Delta removed their assignment Nov 2, 2021
@braders
Copy link

braders commented Nov 9, 2021

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);

@engcom-Hotel engcom-Hotel self-assigned this Nov 9, 2021
@m2-assistant
Copy link

m2-assistant bot commented Nov 9, 2021

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: 👇

  • 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.

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

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

@dborishansky
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

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

@engcom-Hotel
Copy link
Contributor

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

  1. 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 engcom-Hotel added the Issue: needs update Additional information is require, waiting for response label Jan 12, 2022
@wsbrs
Copy link

wsbrs commented Jan 21, 2022

@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

@igi8819
Copy link

igi8819 commented Feb 4, 2022

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));

@m2-assistant
Copy link

m2-assistant bot commented Feb 9, 2022

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: 👇

  • 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.

@engcom-Lima
Copy link
Contributor

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

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

  2. 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-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Feb 15, 2022
@MrBlueEyez
Copy link

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.

@Pranav-242
Copy link

@magento i'm working on it

@tuyennn
Copy link
Member

tuyennn commented Jul 21, 2022

Hi folks, any update on this ticket?

@vpodorozh
Copy link
Contributor

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

@frostitution
Copy link

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?

@github-jira-sync-bot github-jira-sync-bot added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. and removed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Sep 22, 2022
@chittima
Copy link
Contributor

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

@trunglv
Copy link

trunglv commented Nov 7, 2022

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

@chittima
Copy link
Contributor

chittima commented Nov 7, 2022

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

@engcom-Hotel
Copy link
Contributor

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

Thanks

@mhamzaraja
Copy link

mhamzaraja commented Nov 17, 2022

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

@chittima
Copy link
Contributor

Hi @mhamzaraja Please find the commit: b4f87e9

@rendyep
Copy link

rendyep commented Jul 26, 2024

Is patch for 2.4.5-p8 available for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Cart & Checkout Component: Checkout Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Archived in project
Development

No branches or pull requests