magento2: Unable to add new address on checkout
Preconditions (*)
- Magento 2.3.4(release)
Steps to reproduce (*)
- Login as a customer with saved addresses
- Add product to cart
- Open website in incognito mode or clean all cookies and local storage
- Login as a customer from step 1
- Go to checkout
- Add new address
- Select shipping method and click “Continue to payment”
Expected result (*)
- Payment step is opened
Actual result (*)
- Error message “Please specify a regionId in shipping address.” is shown
Additional info
- customer data section
directory-data is empty @see app/vendor/magento/module-checkout/view/frontend/web/js/model/address-converter.js:46
- Caused by https://github.com/magento/magento2/commit/73ba36616fbd3244b75ef07129aeb967c299765f
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 24 (9 by maintainers)
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.
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!?
I can confirm @paras89 method works. If you have the same issue please apply his fix.