Skip to content

Commit

Permalink
ENGCOM-1059: #13765 Excess requests 'customer data' on checkout cart …
Browse files Browse the repository at this point in the history
…page were fixed #14314
  • Loading branch information
Stanislav Idolov committed Apr 19, 2018
2 parents c352078 + 0576581 commit 674a837
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
15 changes: 9 additions & 6 deletions app/code/Magento/Checkout/view/frontend/web/js/model/totals.js
Expand Up @@ -14,17 +14,20 @@ define([
'use strict';

var quoteItems = ko.observable(quote.totals().items),
cartData = customerData.get('cart'),
quoteSubtotal = parseFloat(quote.totals().subtotal),
subtotalAmount = parseFloat(cartData().subtotalAmount);
cartData = customerData.get('cart');

quote.totals.subscribe(function (newValue) {
quoteItems(newValue.items);
});

if (quoteSubtotal !== subtotalAmount) {
customerData.reload(['cart'], false);
}
cartData.subscribe(function () {
var quoteSubtotal = parseFloat(quote.totals().subtotal),
subtotalAmount = parseFloat(cartData().subtotalAmount);

if (quoteSubtotal !== subtotalAmount) {
customerData.reload(['cart'], false);
}
}, this);

return {
totals: quote.totals,
Expand Down
Expand Up @@ -94,17 +94,17 @@ define([
this.isLoading(addToCartCalls > 0);
sidebarInitialized = false;
this.update(updatedCart);

if (cartData()['website_id'] !== window.checkout.websiteId) {
customerData.reload(['cart'], false);
}
initSidebar();
}, this);
$('[data-block="minicart"]').on('contentLoading', function () {
addToCartCalls++;
self.isLoading(true);
});

if (cartData()['website_id'] !== window.checkout.websiteId) {
customerData.reload(['cart'], false);
}

return this._super();
},
isLoading: ko.observable(false),
Expand Down
Expand Up @@ -232,9 +232,11 @@ define([
if (!_.isEmpty(privateContent)) {
countryData = this.get('directory-data');

if (_.isEmpty(countryData())) {
customerData.reload(['directory-data'], false);
}
countryData.subscribe(function () {
if (_.isEmpty(countryData())) {
customerData.reload(['directory-data'], false);
}
}, this);
}
},

Expand Down

0 comments on commit 674a837

Please sign in to comment.