Skip to content

Conversation

codekipple
Copy link

Description

On the cart page the postcode validation can cause a JS error Uncaught TypeError: Cannot read property 'is_zipcode_optional' of undefined.

screen shot 2018-01-08 at 10 23 47

To get this error the Magento store has to have deselected 'United States' in the 'Allowed Countries' admin option. Select any country except 'United States' as the default country:- Admin -> Stores -> configuration -> General -> Default Country

If this is the case then Magento will actually cycle through the update() method in app/code/Magento/Ui/view/base/web/js/form/element/region.js twice. Once with the two letter code for the country selected as the 'Default Country' and once with the 'US' country code regardless ofwhether the 'United States' is selected as the default country. If the 'United States' is deselected in the 'Allowed Countries' when the update() method in region.js runs using a value of 'US' the 'option' variable in the update() method is undefined. This code checks for this scenario and returns early.

Manual testing scenarios

  1. Create a Store using Magento 2.2.2
  2. Select any country except 'United States' as the default country:- Admin -> Stores -> configuration -> General -> Default Country
  3. Deselect 'United States' in the 'Allowed Countries' option:- Admin -> Stores -> configuration -> General -> Allow Countries
    screen shot 2018-01-08 at 10 26 05
  4. Add a product to cart and visit the cart page
  5. Open up your browsers inspect tool to see the JS error

VladimirZaets and others added 5 commits January 8, 2018 09:51
…dation

 - Added handler to enable "Place Order" button on failed validation
 - Covered changes by js unit test
…e can't be empty- Made hidden fields disabled.
…tion' is undefined. This can happen with stores that have a different deault country than US
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jan 8, 2018

CLA assistant check
All committers have signed the CLA.

@codekipple
Copy link
Author

codekipple commented Jan 8, 2018

I closed this pull request and re-created it because I accidentally included other peoples commits.
New pull:- #13051

@codekipple codekipple closed this Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants