After i upgrade from Magento 2.3.4 to Magento 2.4.1 after choosing the shipping address in the checkout page, i got this error:

Please specify regionId in shipping address

then i see the region is missing from the address in checkout page:

enter image description here

after i add new address, the region was not there either enter image description here

before in Magento 2.3.4 it's showing fine like this:

enter image description here


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.