-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkout: ZIP code in shipping address form already validated on page load #7724
Comments
Thanks. Code is working. |
Thanks for the fix |
Hopefully this will be added to 2.1.4 or 2.2. |
issue is still present in 2.1.4 |
thanks for the fix, you saved me a lot |
that works perfect thanks it really saves a lot of time . |
Would it not be easier fto provide in a switch at store level in the configuration for the Postcode prepopulation of "*", because it is causing all sorts of failed transactions for us and no doubt other webstore devs. Many thanks, Guy |
Thanks you very very much. Code working ! @ktruehl |
@ktruehl May please let me know if this issue relevant for latest release of Magento 2? |
The problem also exist in the newest Magento 2.2.5. |
Issue still exists in 2.2.6 |
When loading the checkout page and no shipping address has been saved yet (for example during guest checkout), the ZIP code field will already show as having failed the validation ("this is a required field") without any user interaction.
Preconditions
Steps to reproduce
Expected result
Actual result
Investigation
The problem seems to be that the field value is programmatically set before the page has finished loading. We haven't found out what causes this to happen. However, the problem is that the new value for the field is
undefined
. Then previous value is an empty string. TheequalityComparer
for the ZIP code field is thevaluesArePrimitiveAndEqual(a, b)
method (/lib/web/knockoutjs/knockout.js
). So the methodisDifferent: function(oldValue, newValue)
(/lib/web/knockoutjs/knockout.js
) returns true.Workaround
For all practical purposes we are fine with the empty string being considered equal to
null
orundefined
, so we can replace theequalityComparer
property of the ZIP code field. We can do this by overriding theinitObservable()
method in/vendor/magento/module-ui/view/base/web/js/form/element/post-code.js
. See attached patch.avoid-premature-zip-code-validation-vendor_magento_module-ui_view_base_web_js_form_element_post-code.diff.zip
The text was updated successfully, but these errors were encountered: