Skip to content

Commit e194edc

Browse files
Merge branch 'MAGETWO-91932' into 2.2-develop-pr11
2 parents bc1cd5a + aa1b000 commit e194edc

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

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

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

4141
validators.push(defaultValidator);
@@ -101,7 +101,7 @@ define([
101101

102102
if (element.index === postcodeElementName) {
103103
this.bindHandler(element, delay);
104-
postcodeElement = element;
104+
postcodeElements.push(element);
105105
}
106106
},
107107

@@ -136,7 +136,13 @@ define([
136136
if (!formPopUpState.isVisible()) {
137137
clearTimeout(self.validateAddressTimeout);
138138
self.validateAddressTimeout = setTimeout(function () {
139-
self.postcodeValidation();
139+
if (element.index === postcodeElementName) {
140+
self.postcodeValidation(element);
141+
} else {
142+
$.each(postcodeElements, function (index, elem) {
143+
self.postcodeValidation(elem);
144+
});
145+
}
140146
self.validateFields();
141147
}, delay);
142148
}
@@ -148,8 +154,8 @@ define([
148154
/**
149155
* @return {*}
150156
*/
151-
postcodeValidation: function () {
152-
var countryId = $('select[name="country_id"]').val(),
157+
postcodeValidation: function (postcodeElement) {
158+
var countryId = $('select[name="country_id"]:visible').val(),
153159
validationResult,
154160
warnMessage;
155161

@@ -178,8 +184,8 @@ define([
178184
*/
179185
validateFields: function () {
180186
var addressFlat = addressConverter.formDataProviderToFlatData(
181-
this.collectObservedData(),
182-
'shippingAddress'
187+
this.collectObservedData(),
188+
'shippingAddress'
183189
),
184190
address;
185191

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ define([
1717
'Magento_Customer/js/customer-data',
1818
'Magento_Checkout/js/action/set-billing-address',
1919
'Magento_Ui/js/model/messageList',
20-
'mage/translate'
20+
'mage/translate',
21+
'Magento_Checkout/js/model/shipping-rates-validator'
2122
],
2223
function (
2324
ko,
@@ -33,7 +34,8 @@ function (
3334
customerData,
3435
setBillingAddressAction,
3536
globalMessageList,
36-
$t
37+
$t,
38+
shippingRatesValidator
3739
) {
3840
'use strict';
3941

@@ -71,6 +73,7 @@ function (
7173
quote.paymentMethod.subscribe(function () {
7274
checkoutDataResolver.resolveBillingAddress();
7375
}, this);
76+
shippingRatesValidator.initFields(this.get('name') + '.form-fields');
7477
},
7578

7679
/**

0 commit comments

Comments
 (0)