Skip to content

Commit e62f1f3

Browse files
author
Stanislav Idolov
committed
MAGETWO-52987: Checkout Zip Validation is not working with specific shipping settings
1 parent ef12b17 commit e62f1f3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ define(
2929
var checkoutConfig = window.checkoutConfig,
3030
validators = [],
3131
observedElements = [],
32-
postcodeElement = null;
32+
postcodeElement = null,
33+
postcodeElementName = 'postcode';
3334

3435
return {
3536
validateAddressTimeout: 0,
@@ -50,7 +51,7 @@ define(
5051
* @return {Boolean}
5152
*/
5253
validateAddressData: function (address) {
53-
return validators.some(function(validator) {
54+
return validators.some(function (validator) {
5455
return validator.validate(address);
5556
});
5657
},
@@ -64,6 +65,12 @@ define(
6465
var self = this,
6566
elements = shippingRatesValidationRules.getObservableFields();
6667

68+
//TODO: Split zip code validation and element binding for shipping rates request
69+
if ($.inArray(postcodeElementName, elements) === -1) {
70+
// Add postcode field to observables if not exist for zip code validation support
71+
elements.push(postcodeElementName);
72+
}
73+
6774
$.each(elements, function (index, field) {
6875
uiRegistry.async(formPath + '.' + field)(self.doElementBinding.bind(self));
6976
});
@@ -80,12 +87,12 @@ define(
8087
var observableFields = shippingRatesValidationRules.getObservableFields();
8188

8289
if (element && (observableFields.indexOf(element.index) !== -1 || force)) {
83-
if (element.index !== 'postcode') {
90+
if (element.index !== postcodeElementName) {
8491
this.bindHandler(element, delay);
8592
}
8693
}
8794

88-
if (element.index === 'postcode') {
95+
if (element.index === postcodeElementName) {
8996
this.bindHandler(element, delay);
9097
postcodeElement = element;
9198
}

0 commit comments

Comments
 (0)