magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.3k forks source link

Unable to add new address on checkout #28221

Closed astvdurnev closed 3 years ago

astvdurnev commented 4 years ago

Preconditions (*)

  1. Magento 2.3.4(release)

Steps to reproduce (*)

  1. Login as a customer with saved addresses
  2. Add product to cart
  3. Open website in incognito mode or clean all cookies and local storage
  4. Login as a customer from step 1
  5. Go to checkout
  6. Add new address
  7. Select shipping method and click "Continue to payment"

Expected result (*)

  1. Payment step is opened

Actual result (*)

  1. Error message "Please specify a regionId in shipping address." is shown

Additional info

  1. customer data section directory-data is empty @see app/vendor/magento/module-checkout/view/frontend/web/js/model/address-converter.js:46
  2. Caused by https://github.com/magento/magento2/commit/73ba36616fbd3244b75ef07129aeb967c299765f
m2-assistant[bot] commented 4 years ago

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

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.

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


m2-assistant[bot] commented 4 years ago

Hi @krishprakash. 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:

krishprakash commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

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

magento-engcom-team commented 4 years ago

Hi @krishprakash, here is your Magento instance. Admin access: https://i-28221-2-4-develop.instances.magento-community.engineering/admin_fc36 Login: 8cf1d4b6 Password: 8f7710200e4c Instance will be terminated in up to 3 hours.

krishprakash commented 4 years ago

Hi @AstoundJenkins. Not able to reproduce the issue as provided steps by you Kindly provide more detailed steps with video link if possible so It will help to reproduce issue here Thanks

ben91376 commented 4 years ago

Today, I was on a demo with our client in a staging environment V2.3.5-p1 and encountered the same error in the original description. At some point, the "State" value was removed from my saved address. So during checkout, I was able to see my state (South Carolina) in my address; however, in the admin, I accessed my address again and the state value was missing. Once I added my state again and saved my address, I was able to checkout successfully. At no point, did I provide an action that removed the state value.

happymachines commented 4 years ago

@astvdurnev I was running into the same issue, it turns out the issue stemmed from a theme override of the file vendor/magento/module-customer/view/frontend/web/js/section-config.js. The theme override in my case was missing the changes that appeared in this commit https://github.com/magento/magento2/commit/d57d43a0bf0e620f006fbca9562f70dc3bdc1036#diff-82971003fd8862a51cf2b4e47b34733a

astvdurnev commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

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

magento-engcom-team commented 4 years ago

Hi @astvdurnev, here is your Magento instance. Admin access: https://i-28221-2-4-develop.instances.magento-community.engineering/admin_f4c8 Login: a268848d Password: 7efe6e44b5cc Instance will be terminated in up to 3 hours.

Dnd-Mafer commented 4 years ago

I had the same issue 100% of the time : customer/online_customers/section_data_lifetime configuration was set to "" in database ...

grichards commented 4 years ago

I am experiencing the same issue in 2.3.4.

As a logged in user who already has a saved address, if I attempt to add a new address, the State / Region does not save.

erikhansen commented 4 years ago

One of my merchants running 2.3.4-p2 had a customer report this issue to them. However I logged in as that customer (using this extension) and was able to add a new address just fine. Has anyone come up with steps to consistently reproduce this issue on Magento 2.3.x?

paras89 commented 4 years ago

I was able to reproduce the issue using the steps given in steps to reproduce on Magento 2.3.5-p2.

Used the JS debugger to figure the error was coming from here: https://github.com/magento/magento2/blob/2.3.5-p2/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js#L340

On that line, the code looks for region in the shippingAddress observable but when saving a new address for a not logged in user, in this case Magento is not setting the "region" property on the shippingAddress object, instead only regionId is set since the name of the region dropdown field for US is regionId.

As a workaround on line 212 of shipping.js I would add: var regionSelector = '#co-shipping-form select[name=region_id] option:selected'; if (addressData['region_id'] == $(regionSelector).val()) { addressData['region'] = $(regionSelector).text(); }

This is not the perfect framework fix, but should be safe enough for anyone looking to resolve this important checkout issue.

m2-assistant[bot] commented 3 years ago

Hi @engcom-Bravo. 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:

engcom-Bravo commented 3 years ago

Hello @astvdurnev

Thank you for your report.

This issue seems to be fixed on the latest Magento 2.4-develop version.

Manual testing scenario:

  1. Login as a customer with saved addresses
  2. Add product to cart Login
  3. Open website in incognito mode or clean all cookies and local storage
  4. Login as a customer from step 1
  5. Go to checkout
  6. Add new address Add new address
  7. Select shipping method and click "Continue to payment"

Actual result: Payment Method page appears without errors Place order page

We are closing this issue. Please feel free to comment, reopen or create new ticket according to the [Issue reporting guidelines]

nickpiro commented 3 years ago

So this is closed because it's fixed in 2.4.x? But where was it fixed? We're running 2.3.6, how do we correct it there!?

pyyick commented 3 years ago

I can confirm @paras89 method works. If you have the same issue please apply his fix.

sunilit42 commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

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

magento-deployment-service[bot] commented 2 years ago

Hi @sunilit42, here is your Magento Instance: https://e3b73826441e47cc6b6f4f7f7347f749.instances.magento-community.engineering Admin access: https://e3b73826441e47cc6b6f4f7f7347f749.instances.magento-community.engineering/admin_36c0 Login: fc04ea3c Password: 18eebca0ae83

Stoyvo commented 2 years ago

I was able to recreate this. Magento 2.4.4

A customer is signed into their account, with no address saved. An admin will create an address for the customer (billing, shipping are the same). Customer will add items to cart and proceed to checkout. Customer will not be able to proceed to Payment step. (Please specify a regionId in shipping address.) Address shown to customer is missing region (Eg: Alberta in Canada is missing) Admin can see province/region assigned to the customer in their saved addresses.

If customer signs out, flushes all cookies/local storage, and signs back in, then the checkout process will work.

erikhansen commented 7 months ago

@paras89 We've been continuing to experience this issue on Magento Commerce 2.4.4-p6. Your solution helped workaround the issue, thanks.

For everyone else's benefit, I added this code:

                // BEGIN EDIT - Fix issue with "Please specify a regionId in shipping address" for small subset of logged in customers
                // See https://github.com/magento/magento2/issues/28221#issuecomment-694786633 for context
                var regionSelector = '#co-shipping-form select[name=region_id] option:selected';
                if (addressData['region_id'] == $(regionSelector).val()) {
                    addressData['region'] = $(regionSelector).text();
                }
                // END EDIT

Below this line (line number changed since 2020): https://github.com/magento/magento2/blob/2.4.4-p6/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js#L244

The steps I found to reproduce the issue were:

  1. In an incognito window, login to admin and locate a customer account for a customer who already had items in their cart
  2. Login as the customer
  3. Go directly to /checkout/
  4. Add a new address
  5. Click "Next"

Expected result

You'll be able to proceed

Actual result

You'll see an error like this: Please specify a regionId in shipping address