Skip to content

Commit 3861279

Browse files
MAGETWO-91932: Zip code is not validated during checkout when "My billing and shipping address are the same" is unchecked
1 parent e6d4857 commit 3861279

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ define([
3535
var checkoutConfig = window.checkoutConfig,
3636
validators = [],
3737
observedElements = [],
38+
postcodeElements = [],
3839
postcodeElementName = 'postcode';
3940

4041
validators.push(defaultValidator);
@@ -78,11 +79,7 @@ define([
7879
}
7980

8081
$.each(elements, function (index, field) {
81-
var elementBinding = self.doElementBinding.bind(self),
82-
fullPath = formPath + '.' + field,
83-
func = uiRegistry.async(fullPath);
84-
85-
func(elementBinding);
82+
uiRegistry.async(formPath + '.' + field)(self.doElementBinding.bind(self));
8683
});
8784
},
8885

@@ -104,6 +101,7 @@ define([
104101

105102
if (element.index === postcodeElementName) {
106103
this.bindHandler(element, delay);
104+
postcodeElements.push(element);
107105
}
108106
},
109107

@@ -138,7 +136,13 @@ define([
138136
if (!formPopUpState.isVisible()) {
139137
clearTimeout(self.validateAddressTimeout);
140138
self.validateAddressTimeout = setTimeout(function () {
141-
self.postcodeValidation(element);
139+
if (element.index === postcodeElementName) {
140+
self.postcodeValidation(element);
141+
} else {
142+
$.each(postcodeElements, function (index, elem) {
143+
self.postcodeValidation(elem);
144+
});
145+
}
142146
self.validateFields();
143147
}, delay);
144148
}
@@ -151,7 +155,7 @@ define([
151155
* @return {*}
152156
*/
153157
postcodeValidation: function (postcodeElement) {
154-
var countryId = $('select[name="country_id"]').val(),
158+
var countryId = $('select[name="country_id"]:visible').val(),
155159
validationResult,
156160
warnMessage;
157161

0 commit comments

Comments
 (0)