Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/code/Magento/Checkout/view/frontend/web/js/model/totals.js
Original file line number Diff line number Diff line change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that it will starts to poll remote call after every second in those setups where are defined also taxes as quote.totals().subtotal returns amount without tax but cartData().subtotalAmount is with tax.

Replacing subtotal with subtotal_incl_tax seems to make them equal

- var quoteSubtotal = parseFloat(quote.totals().subtotal),
+ var quoteSubtotal = parseFloat(quote.totals().subtotal_incl_tax),

}
}, this);

return {
totals: quote.totals,
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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