Open m2-assistant[bot] opened 2 years ago
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: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If 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
branchDetails
- 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.
Hello @TravisBernard,
We have tried to reproduce the issue in Magento 2.4-develop branch and the issue is reproducible for us. We have a registered user with both US and UK address. For US address region information is present but fir UK address region is shown as null
. Please refer the below screenshot for reference:
For US Address
For UK Address
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-2831 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
This issue is automatically created based on existing pull request: magento/magento2#34482: Bug Fix: Missing region on shipping with some saved addresses
Description (*)
When shipping using a saved address outside of the US/CA the
dest_region_code
is empty. For example a saved address in the UK will expose the problem. I traced the issue back to the Customer\Model\Address\AbstractAddress class's getRegionCode method.getRegionCode assumes there will be a valid
region_id
- which there isn't in this case - or that theregion
field will be a usable string instead. However when converting the saved address into a quote address theregion
field is parsed as an associative array with three parts -region
,region_code
, andregion_id
. So in this casegetRegionCode
needs an additional check to use$region['region_code']
if available.I've added a test to expose the problem and prove the fix. The test is
Magento\Customer\Test\Unit\Model\Address\AbstractAddressTest::testGetRegionCodeWithRegionArray
Fixed Issues (if relevant)
I've not raised a separate issue, I'm using this PR as the bug report
Manual testing scenarios (*)
I've provided a unit test that exposes the problem
This cannot be fully seen in the store's checkout with the builtin shipping methods as none of them support region based shipping outside the US/CA. It does impact 3rd party shipping extensions however.
To manually test you'll have to use the debugger to view the details of the RateRequest when it's passed to one of the shipping carriers. For example put a breakpoint at the top of
Magento\OfflineShipping\Model\Carrier\Flatrate::collectRates
Essex
.$request->getDestRegionCode()
Expected:
"Essex"
Actual:null
Questions or comments
There is an unrelated test that was failing for me before I made my changes. All tests related to shipping and address handling including my new test pass.
Contribution checklist (*)