Skip to content

Commit 7409c8e

Browse files
MAGETWO-96850: [2.3.x] One page Checkout resets Customer data if Product Qty was changed
- Changed the logic of getting checkout data
1 parent 8c2e178 commit 7409c8e

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
*/
1111
define([
1212
'jquery',
13-
'Magento_Customer/js/customer-data'
13+
'Magento_Customer/js/customer-data',
14+
'jquery/jquery-storageapi'
1415
], function ($, storage) {
1516
'use strict';
1617

@@ -30,20 +31,27 @@ define([
3031
var data = storage.get(cacheKey)();
3132

3233
if ($.isEmptyObject(data)) {
33-
data = {
34-
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage
35-
'shippingAddressFromData': null, //Shipping address pulled from persistence storage
36-
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for customer
37-
'selectedShippingRate': null, //Shipping rate pulled from persistence storage
38-
'selectedPaymentMethod': null, //Payment method pulled from persistence storage
39-
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage
40-
'billingAddressFromData': null, //Billing address pulled from persistence storage
41-
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer
42-
};
43-
saveData(data);
34+
data = $.initNamespaceStorage('mage-cache-storage').localStorage.get(cacheKey);
35+
if ($.isEmptyObject(data)) {
36+
data = initData();
37+
saveData(data);
38+
}
4439
}
4540

4641
return data;
42+
},
43+
44+
initData = function () {
45+
return {
46+
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage
47+
'shippingAddressFromData': null, //Shipping address pulled from persistence storage
48+
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for customer
49+
'selectedShippingRate': null, //Shipping rate pulled from persistence storage
50+
'selectedPaymentMethod': null, //Payment method pulled from persistence storage
51+
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage
52+
'billingAddressFromData': null, //Billing address pulled from persistence storage
53+
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer
54+
}
4755
};
4856

4957
return {

0 commit comments

Comments
 (0)