Skip to content

Commit a9ceb1a

Browse files
authored
Merge pull request #4532 from magento-performance/MC-18191
MC-18191: customer section problem
2 parents 4184f63 + 4cd8e10 commit a9ceb1a

File tree

4 files changed

+5
-36
lines changed

4 files changed

+5
-36
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,7 @@ define([
8787
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
8888
}
8989

90-
if (!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
91-
!cartCache.isChanged('shippingMethodCode', data.shippingMethodCode) &&
92-
!cartCache.isChanged('shippingCarrierCode', data.shippingCarrierCode) &&
93-
!cartCache.isChanged('address', address) &&
94-
cartCache.get('totals') &&
95-
!cartCache.isChanged('subtotal', parseFloat(quote.totals().subtotal))
96-
) {
97-
quote.setTotals(cartCache.get('totals'));
98-
} else {
99-
return loadFromServer(address);
100-
}
90+
return loadFromServer(address);
10191
}
10292
};
10393
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ define([
102102
self.isLoading(true);
103103
});
104104

105-
if (cartData().website_id !== window.checkout.websiteId ||
106-
cartData().store_id !== window.checkout.storeId
105+
if (
106+
cartData().website_id !== window.checkout.websiteId &&
107+
cartData().website_id !== undefined
107108
) {
108109
customerData.reload(['cart'], false);
109110
}

app/code/Magento/Persistent/Test/Mftf/Test/ShippingQuotePersistedForGuestTest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
<resetCookie userInput="persistent_shopping_cart" stepKey="resetPersistentCookie"/>
5555
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnHomePageAfterResetPersistentCookie"/>
5656
<waitForPageLoad stepKey="waitHomePageLoadAfterResetCookie"/>
57-
<!--Check that the minicart is empty-->
58-
<actionGroup ref="assertMiniCartEmpty" after="waitHomePageLoadAfterResetCookie" stepKey="seeMinicartEmpty"/>
5957
<!--Step 4: Add the product to shopping cart and open cart-->
6058
<amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToProductPageAsGuestUser"/>
6159
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToCartAsGuestUser">

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ define([
2323
result = {
2424
totals: 10
2525
},
26-
totals = {
27-
grandTotal: 5
28-
},
2926
address = {
3027
countryId: 'US',
3128
region: null,
@@ -98,20 +95,6 @@ define([
9895

9996
describe('Magento_Checkout/js/model/cart/totals-processor/default', function () {
10097

101-
it('estimateTotals if data was cached', function () {
102-
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'isChanged').and.returnValue(false);
103-
spyOn(mocks['Magento_Customer/js/customer-data'], 'get').and.returnValue(
104-
ko.observable({
105-
'data_id': 1
106-
})
107-
);
108-
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'get').and.returnValue(totals);
109-
spyOn(mocks['mage/storage'], 'post');
110-
expect(defaultProcessor.estimateTotals(address)).toBeUndefined();
111-
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
112-
expect(mocks['mage/storage'].post).not.toHaveBeenCalled();
113-
});
114-
11598
it('estimateTotals if data wasn\'t cached and request was successfully sent', function () {
11699
var deferral = new $.Deferred();
117100

@@ -129,12 +112,10 @@ define([
129112
return deferral.resolve(result);
130113
});
131114
expect(defaultProcessor.estimateTotals(address)).toBe(deferral);
132-
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
115+
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(result);
133116
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
134117
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
135118
expect(mocks['mage/storage'].post).toHaveBeenCalled();
136-
expect(mocks['Magento_Checkout/js/model/cart/cache'].get).not.toHaveBeenCalled();
137-
expect(mocks['Magento_Checkout/js/model/cart/cache'].set).toHaveBeenCalledWith('cart-data', data);
138119
});
139120

140121
it('estimateTotals if data wasn\'t cached and request returns error', function () {
@@ -154,7 +135,6 @@ define([
154135
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
155136
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
156137
expect(mocks['mage/storage'].post).toHaveBeenCalled();
157-
expect(mocks['Magento_Checkout/js/model/cart/cache'].get).not.toHaveBeenCalled();
158138
expect(mocks['Magento_Checkout/js/model/error-processor'].process).toHaveBeenCalledWith('Error Message');
159139
});
160140
});

0 commit comments

Comments
 (0)