Skip to content

Commit 6e86e50

Browse files
author
Oleksii Korshenko
authored
MAGETWO-68877: Issue #7988 Typo changed also added comments for each index, getters and setters. #9484
2 parents 86de5ed + 0c520a2 commit 6e86e50

File tree

1 file changed

+60
-22
lines changed

1 file changed

+60
-22
lines changed

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

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,40 @@ define([
1515
'use strict';
1616

1717
var cacheKey = 'checkout-data',
18+
checkoutData,
1819

1920
/**
20-
* @param {Object} data
21+
* @return {*}
2122
*/
22-
saveData = function (data) {
23-
storage.set(cacheKey, data);
23+
getData = function () {
24+
return storage.get(cacheKey)();
2425
},
2526

2627
/**
27-
* @return {*}
28+
* @param {Object} data
2829
*/
29-
getData = function () {
30-
var data = storage.get(cacheKey)();
31-
32-
if ($.isEmptyObject(data)) {
33-
data = {
34-
'selectedShippingAddress': null,
35-
'shippingAddressFromData': null,
36-
'newCustomerShippingAddress': null,
37-
'selectedShippingRate': null,
38-
'selectedPaymentMethod': null,
39-
'selectedBillingAddress': null,
40-
'billingAddressFormData': null,
41-
'newCustomerBillingAddress': null
42-
};
43-
saveData(data);
44-
}
45-
46-
return data;
30+
saveData = function (data) {
31+
storage.set(cacheKey, data);
32+
};
33+
34+
if ($.isEmptyObject(getData())) {
35+
checkoutData = {
36+
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage.
37+
'shippingAddressFromData': null, //Shipping address pulled from persistence storage.
38+
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for new customer.
39+
'selectedShippingRate': null, //Shipping rate pulled from persistence storage.
40+
'selectedPaymentMethod': null, //Payment method pulled from persistence storage.
41+
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage.
42+
'billingAddressFromData': null, //Billing address pulled from persistence storage.
43+
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer.
4744
};
45+
saveData(checkoutData);
46+
}
4847

4948
return {
5049
/**
50+
* Setting the selected shipping address pulled from persistence storage.
51+
*
5152
* @param {Object} data
5253
*/
5354
setSelectedShippingAddress: function (data) {
@@ -58,13 +59,17 @@ define([
5859
},
5960

6061
/**
62+
* Pulling the selected shipping address from persistence storage.
63+
*
6164
* @return {*}
6265
*/
6366
getSelectedShippingAddress: function () {
6467
return getData().selectedShippingAddress;
6568
},
6669

6770
/**
71+
* Setting the shipping address pulled from persistence storage.
72+
*
6873
* @param {Object} data
6974
*/
7075
setShippingAddressFromData: function (data) {
@@ -75,13 +80,17 @@ define([
7580
},
7681

7782
/**
83+
* Pulling the shipping address from persistence storage.
84+
*
7885
* @return {*}
7986
*/
8087
getShippingAddressFromData: function () {
8188
return getData().shippingAddressFromData;
8289
},
8390

8491
/**
92+
* Setting the shipping address pulled from persistence storage for new customer.
93+
*
8594
* @param {Object} data
8695
*/
8796
setNewCustomerShippingAddress: function (data) {
@@ -92,13 +101,17 @@ define([
92101
},
93102

94103
/**
104+
* Pulling the shipping address from persistence storage for new customer.
105+
*
95106
* @return {*}
96107
*/
97108
getNewCustomerShippingAddress: function () {
98109
return getData().newCustomerShippingAddress;
99110
},
100111

101112
/**
113+
* Setting the selected shipping rate pulled from persistence storage.
114+
*
102115
* @param {Object} data
103116
*/
104117
setSelectedShippingRate: function (data) {
@@ -109,13 +122,17 @@ define([
109122
},
110123

111124
/**
125+
* Pulling the selected shipping rate from local storge
126+
*
112127
* @return {*}
113128
*/
114129
getSelectedShippingRate: function () {
115130
return getData().selectedShippingRate;
116131
},
117132

118133
/**
134+
* Setting the selected payment method pulled from persistence storage.
135+
*
119136
* @param {Object} data
120137
*/
121138
setSelectedPaymentMethod: function (data) {
@@ -126,13 +143,17 @@ define([
126143
},
127144

128145
/**
146+
* Pulling the payment method from persistence storage.
147+
*
129148
* @return {*}
130149
*/
131150
getSelectedPaymentMethod: function () {
132151
return getData().selectedPaymentMethod;
133152
},
134153

135154
/**
155+
* Setting the selected billing address pulled from persistence storage.
156+
*
136157
* @param {Object} data
137158
*/
138159
setSelectedBillingAddress: function (data) {
@@ -143,13 +164,17 @@ define([
143164
},
144165

145166
/**
167+
* Pulling the selected billing address from persistence storage.
168+
*
146169
* @return {*}
147170
*/
148171
getSelectedBillingAddress: function () {
149172
return getData().selectedBillingAddress;
150173
},
151174

152175
/**
176+
* Setting the billing address pulled from persistence storage.
177+
*
153178
* @param {Object} data
154179
*/
155180
setBillingAddressFromData: function (data) {
@@ -160,13 +185,16 @@ define([
160185
},
161186

162187
/**
188+
* Pulling the billing address from persistence storage.
163189
* @return {*}
164190
*/
165191
getBillingAddressFromData: function () {
166192
return getData().billingAddressFromData;
167193
},
168194

169195
/**
196+
* Setting the billing address pulled from persistence storage for new customer.
197+
*
170198
* @param {Object} data
171199
*/
172200
setNewCustomerBillingAddress: function (data) {
@@ -177,13 +205,17 @@ define([
177205
},
178206

179207
/**
208+
* Pulling the billing address from persistence storage for new customer.
209+
*
180210
* @return {*}
181211
*/
182212
getNewCustomerBillingAddress: function () {
183213
return getData().newCustomerBillingAddress;
184214
},
185215

186216
/**
217+
* Pulling the email address from persistence storage.
218+
*
187219
* @return {*}
188220
*/
189221
getValidatedEmailValue: function () {
@@ -193,6 +225,8 @@ define([
193225
},
194226

195227
/**
228+
* Setting the email address pulled from persistence storage.
229+
*
196230
* @param {String} email
197231
*/
198232
setValidatedEmailValue: function (email) {
@@ -203,6 +237,8 @@ define([
203237
},
204238

205239
/**
240+
* Pulling the email input field value from persistence storage.
241+
*
206242
* @return {*}
207243
*/
208244
getInputFieldEmailValue: function () {
@@ -212,6 +248,8 @@ define([
212248
},
213249

214250
/**
251+
* Setting the email input field value pulled from persistence storage.
252+
*
215253
* @param {String} email
216254
*/
217255
setInputFieldEmailValue: function (email) {

0 commit comments

Comments
 (0)