Skip to content

Commit 8c554b9

Browse files
author
Stanislav Idolov
authored
ENGCOM-1347: [Forwardport] #13765 Excess requests 'customer data' on checkout cart page were fixed #14782
2 parents 0bf843a + 2509886 commit 8c554b9

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/totals.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ define([
1414
'use strict';
1515

1616
var quoteItems = ko.observable(quote.totals().items),
17-
cartData = customerData.get('cart'),
18-
quoteSubtotal = parseFloat(quote.totals().subtotal),
19-
subtotalAmount = parseFloat(cartData().subtotalAmount);
17+
cartData = customerData.get('cart');
2018

2119
quote.totals.subscribe(function (newValue) {
2220
quoteItems(newValue.items);
2321
});
2422

25-
if (quoteSubtotal !== subtotalAmount) {
26-
customerData.reload(['cart'], false);
27-
}
23+
cartData.subscribe(function () {
24+
var quoteSubtotal = parseFloat(quote.totals().subtotal),
25+
subtotalAmount = parseFloat(cartData().subtotalAmount);
26+
27+
if (quoteSubtotal !== subtotalAmount) {
28+
customerData.reload(['cart'], false);
29+
}
30+
}, this);
2831

2932
return {
3033
totals: quote.totals,

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ define([
9494
this.isLoading(addToCartCalls > 0);
9595
sidebarInitialized = false;
9696
this.update(updatedCart);
97+
98+
if (cartData()['website_id'] !== window.checkout.websiteId) {
99+
customerData.reload(['cart'], false);
100+
}
97101
initSidebar();
98102
}, this);
99103
$('[data-block="minicart"]').on('contentLoading', function () {
100104
addToCartCalls++;
101105
self.isLoading(true);
102106
});
103107

104-
if (cartData()['website_id'] !== window.checkout.websiteId) {
105-
customerData.reload(['cart'], false);
106-
}
107-
108108
return this._super();
109109
},
110110
isLoading: ko.observable(false),

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ define([
232232
if (!_.isEmpty(privateContent)) {
233233
countryData = this.get('directory-data');
234234

235-
if (_.isEmpty(countryData())) {
236-
customerData.reload(['directory-data'], false);
237-
}
235+
countryData.subscribe(function () {
236+
if (_.isEmpty(countryData())) {
237+
customerData.reload(['directory-data'], false);
238+
}
239+
}, this);
238240
}
239241
},
240242

0 commit comments

Comments
 (0)