Skip to content

Commit 34c8f2d

Browse files
committed
Merge branch 'FearlessKiwis-MAGETWO-55301' into MAGETWO-63731-Site-Map
2 parents e22de8e + 8f6eb29 commit 34c8f2d

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ define([
1919
quote.shippingAddress.subscribe(function () {
2020
var type = quote.shippingAddress().getType();
2121

22-
if (quote.isVirtual()) {
22+
if (
23+
quote.isVirtual() ||
24+
window.checkoutConfig.activeCarriers && window.checkoutConfig.activeCarriers.length === 0
25+
) {
2326
// update totals block when estimated address was set
2427
totalsProcessors['default'] = totalsDefaultProvider;
2528
totalsProcessors[type] ?
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([], function () {
7+
'use strict';
8+
9+
return {
10+
/**
11+
* @return {Object}
12+
*/
13+
getRules: function () {
14+
return {
15+
'country_id': {
16+
'required': true
17+
}
18+
};
19+
}
20+
};
21+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'mageUtils',
9+
'./default-validation-rules',
10+
'mage/translate'
11+
], function ($, utils, validationRules, $t) {
12+
'use strict';
13+
14+
return {
15+
validationErrors: [],
16+
17+
/**
18+
* @param {Object} address
19+
* @return {Boolean}
20+
*/
21+
validate: function (address) {
22+
var self = this;
23+
24+
this.validationErrors = [];
25+
$.each(validationRules.getRules(), function (field, rule) {
26+
var message;
27+
28+
if (rule.required && utils.isEmpty(address[field])) {
29+
message = $t('Field ') + field + $t(' is required.');
30+
31+
self.validationErrors.push(message);
32+
}
33+
});
34+
35+
return !this.validationErrors.length;
36+
}
37+
};
38+
});

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ define([
1313
'../model/address-converter',
1414
'../action/select-shipping-address',
1515
'./postcode-validator',
16+
'./default-validator',
1617
'mage/translate',
1718
'uiRegistry',
1819
'Magento_Checkout/js/model/shipping-address/form-popup-state',
@@ -24,6 +25,7 @@ define([
2425
addressConverter,
2526
selectShippingAddress,
2627
postcodeValidator,
28+
defaultValidator,
2729
$t,
2830
uiRegistry,
2931
formPopUpState
@@ -36,6 +38,8 @@ define([
3638
postcodeElement = null,
3739
postcodeElementName = 'postcode';
3840

41+
validators.push(defaultValidator);
42+
3943
return {
4044
validateAddressTimeout: 0,
4145
validateDelay: 2000,

0 commit comments

Comments
 (0)