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

Checkout. Quote Address Street cloning issue #26276

Closed
yutv opened this issue Jan 6, 2020 · 11 comments
Closed

Checkout. Quote Address Street cloning issue #26276

yutv opened this issue Jan 6, 2020 · 11 comments
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reported on 2.3.3 Indicates original Magento version for the Issue report.

Comments

@yutv
Copy link

yutv commented Jan 6, 2020

Preconditions (*)

  1. Magento 2.3.3 or 2.4-develop
  2. Logged in Customer with an Address marked both as Shipping and as Billing.

Steps to reproduce (*)

  1. Add a product to cart and go to the second step of checkout.

  2. Open developer console and change billing address. e.g.

     require('Magento_Checkout/js/model/quote').billingAddress().street[0] = '123 Main Street'
    

Expected result (*)

  1. Shipping Address remains the same

Actual result (*)

  1. Shipping address street is changed to "123 Main Street"

image

Cloning Issue

The issue is here app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js#L21

and can be fixed by replacing:

address = $.extend({}, billingAddress);

to

address = $.extend(true, {}, billingAddress);

to clone address recursively including the street array.

@m2-assistant
Copy link

m2-assistant bot commented Jan 6, 2020

Hi @yutv. 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.

@yutv do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 6, 2020
@sudheers-kensium sudheers-kensium self-assigned this Jan 6, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jan 6, 2020

Hi @sudheers-kensium. 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.

@sudheers-kensium
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @sudheers-kensium. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @sudheers-kensium, here is your Magento instance.
Admin access: https://i-26276-2-4-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@sudheers-kensium
Copy link
Contributor

Hello @yutv , This is not an issue. It is working as expected because you marked both Shipping and as Billing address same.

I am closing this issue. Feel free to reopen if you feel that this is Magento core issue.

@yutv
Copy link
Author

yutv commented Jan 6, 2020

@sudheers-kensium

No, you are wrong. There is a bug. As you can see from the screenshot, changing the billing city doesn't lead to changing shipping city, but changing billing street does. An experienced front end developer may confirm that the issue exists.

@magento-engcom-team
Copy link
Contributor

Hi @yutv. Thank you for your report.
The issue has been fixed in #26279 by @yutv in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Feb 13, 2020
magento-engcom-team added a commit that referenced this issue Feb 13, 2020
…eet #26279

 - Merge Pull Request #26279 from yutv/magento2:fix_cloning_quote_billing_addres_street
 - Merged commits:
   1. 2687221
   2. 4e81fd8
   3. 974f5e9
@magento-engcom-team magento-engcom-team added the Reported on 2.3.3 Indicates original Magento version for the Issue report. label Nov 13, 2020
@Ig0r-M-magic42
Copy link

@yutv @sudheers-kensium @magento-engcom-team commit 2687221#diff-e96dae14765cbb77c452167706254377f17c2c2821f689958e306c9c4f81169b
introduced following but for a problem (on 2.4.2)
image

This is due to cloning that adds a bunch of function on top of data, see below:
One magento project
image

Another magento project on 2.4.2
image

Unfortunately i cannot confirm at this point steps to replicate as it's different from these 2 projects, but essentially reverting 2687221#diff-e96dae14765cbb77c452167706254377f17c2c2821f689958e306c9c4f81169b fixed it for me.

Any advice on this matter?

@yutv
Copy link
Author

yutv commented May 6, 2021

Hello @Ig0r-M-magic42,

Most probably you have Google Tag Manager (GTM) enabled on Magento EE/Cloud version. It has the 'prototype' dependency in the vendor/magento/module-google-tag-manager/view/frontend/web/js/google-analytics-universal.js which causes Array.prototype changes and as result leads to strange billing address output on checkout. See similar issue #25684. Eventually the issue in the prototype library.

As a hotfix the following patch may be used.

diff '--exclude=.git' -ruN a/view/frontend/web/js/action/select-billing-address.js b/view/frontend/web/js/action/select-billing-address.js
--- a/view/frontend/web/js/action/select-billing-address.js	2020-11-18 16:06:30.577137247 +0200
+++ b/view/frontend/web/js/action/select-billing-address.js	2020-11-18 16:06:56.153010452 +0200
@@ -19,6 +19,7 @@
             quote.shippingAddress().getCacheKey()
         ) {
-            address = $.extend(true, {}, billingAddress);
+            address = $.extend({}, billingAddress);
+            address.street = (billingAddress.street || []).slice(0);
             address.saveInAddressBook = null;
         } else {
             address = billingAddress;

It resolves the issue on checkout but there are other occurrences of $.extend(true, {}, in the native Magento code, so similar issue may appear in order places: https://github.com/magento/magento2/search?q=%24.extend%28true%2C+%7B%7D%2C&type=code.

@Ig0r-M-magic42
Copy link

@yutv thanks for the feedback, it's quite helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reported on 2.3.3 Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests

5 participants