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);
}
}, 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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this file is using not at checkout page only, so window.checkout will not be available

Copy link
Contributor Author

@andrewbess andrewbess Mar 26, 2018

Choose a reason for hiding this comment

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

@ihor-sviziev
I checked your comment.
window.checkout is available on home page and category pages.
2018-03-26 09-51-13
Also, I want to tell you, that logic "cartData()['website_id'] !== window.checkout.websiteId" was earlier in Magento.
It was fixed it to remove excessed request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will review deeper little bit later

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm that window.checkout property exist at any page where present minicart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, @sidolov
Please check and approve this PR.
Thanks for advance.

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