@@ -15,39 +15,40 @@ define([
15
15
'use strict' ;
16
16
17
17
var cacheKey = 'checkout-data' ,
18
+ checkoutData ,
18
19
19
20
/**
20
- * @param { Object } data
21
+ * @return { * }
21
22
*/
22
- saveData = function ( data ) {
23
- storage . set ( cacheKey , data ) ;
23
+ getData = function ( ) {
24
+ return storage . get ( cacheKey ) ( ) ;
24
25
} ,
25
26
26
27
/**
27
- * @return { * }
28
+ * @param { Object } data
28
29
*/
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.
47
44
} ;
45
+ saveData ( checkoutData ) ;
46
+ }
48
47
49
48
return {
50
49
/**
50
+ * Setting the selected shipping address pulled from persistence storage.
51
+ *
51
52
* @param {Object } data
52
53
*/
53
54
setSelectedShippingAddress : function ( data ) {
@@ -58,13 +59,17 @@ define([
58
59
} ,
59
60
60
61
/**
62
+ * Pulling the selected shipping address from persistence storage.
63
+ *
61
64
* @return {* }
62
65
*/
63
66
getSelectedShippingAddress : function ( ) {
64
67
return getData ( ) . selectedShippingAddress ;
65
68
} ,
66
69
67
70
/**
71
+ * Setting the shipping address pulled from persistence storage.
72
+ *
68
73
* @param {Object } data
69
74
*/
70
75
setShippingAddressFromData : function ( data ) {
@@ -75,13 +80,17 @@ define([
75
80
} ,
76
81
77
82
/**
83
+ * Pulling the shipping address from persistence storage.
84
+ *
78
85
* @return {* }
79
86
*/
80
87
getShippingAddressFromData : function ( ) {
81
88
return getData ( ) . shippingAddressFromData ;
82
89
} ,
83
90
84
91
/**
92
+ * Setting the shipping address pulled from persistence storage for new customer.
93
+ *
85
94
* @param {Object } data
86
95
*/
87
96
setNewCustomerShippingAddress : function ( data ) {
@@ -92,13 +101,17 @@ define([
92
101
} ,
93
102
94
103
/**
104
+ * Pulling the shipping address from persistence storage for new customer.
105
+ *
95
106
* @return {* }
96
107
*/
97
108
getNewCustomerShippingAddress : function ( ) {
98
109
return getData ( ) . newCustomerShippingAddress ;
99
110
} ,
100
111
101
112
/**
113
+ * Setting the selected shipping rate pulled from persistence storage.
114
+ *
102
115
* @param {Object } data
103
116
*/
104
117
setSelectedShippingRate : function ( data ) {
@@ -109,13 +122,17 @@ define([
109
122
} ,
110
123
111
124
/**
125
+ * Pulling the selected shipping rate from local storge
126
+ *
112
127
* @return {* }
113
128
*/
114
129
getSelectedShippingRate : function ( ) {
115
130
return getData ( ) . selectedShippingRate ;
116
131
} ,
117
132
118
133
/**
134
+ * Setting the selected payment method pulled from persistence storage.
135
+ *
119
136
* @param {Object } data
120
137
*/
121
138
setSelectedPaymentMethod : function ( data ) {
@@ -126,13 +143,17 @@ define([
126
143
} ,
127
144
128
145
/**
146
+ * Pulling the payment method from persistence storage.
147
+ *
129
148
* @return {* }
130
149
*/
131
150
getSelectedPaymentMethod : function ( ) {
132
151
return getData ( ) . selectedPaymentMethod ;
133
152
} ,
134
153
135
154
/**
155
+ * Setting the selected billing address pulled from persistence storage.
156
+ *
136
157
* @param {Object } data
137
158
*/
138
159
setSelectedBillingAddress : function ( data ) {
@@ -143,13 +164,17 @@ define([
143
164
} ,
144
165
145
166
/**
167
+ * Pulling the selected billing address from persistence storage.
168
+ *
146
169
* @return {* }
147
170
*/
148
171
getSelectedBillingAddress : function ( ) {
149
172
return getData ( ) . selectedBillingAddress ;
150
173
} ,
151
174
152
175
/**
176
+ * Setting the billing address pulled from persistence storage.
177
+ *
153
178
* @param {Object } data
154
179
*/
155
180
setBillingAddressFromData : function ( data ) {
@@ -160,13 +185,16 @@ define([
160
185
} ,
161
186
162
187
/**
188
+ * Pulling the billing address from persistence storage.
163
189
* @return {* }
164
190
*/
165
191
getBillingAddressFromData : function ( ) {
166
192
return getData ( ) . billingAddressFromData ;
167
193
} ,
168
194
169
195
/**
196
+ * Setting the billing address pulled from persistence storage for new customer.
197
+ *
170
198
* @param {Object } data
171
199
*/
172
200
setNewCustomerBillingAddress : function ( data ) {
@@ -177,13 +205,17 @@ define([
177
205
} ,
178
206
179
207
/**
208
+ * Pulling the billing address from persistence storage for new customer.
209
+ *
180
210
* @return {* }
181
211
*/
182
212
getNewCustomerBillingAddress : function ( ) {
183
213
return getData ( ) . newCustomerBillingAddress ;
184
214
} ,
185
215
186
216
/**
217
+ * Pulling the email address from persistence storage.
218
+ *
187
219
* @return {* }
188
220
*/
189
221
getValidatedEmailValue : function ( ) {
@@ -193,6 +225,8 @@ define([
193
225
} ,
194
226
195
227
/**
228
+ * Setting the email address pulled from persistence storage.
229
+ *
196
230
* @param {String } email
197
231
*/
198
232
setValidatedEmailValue : function ( email ) {
@@ -203,6 +237,8 @@ define([
203
237
} ,
204
238
205
239
/**
240
+ * Pulling the email input field value from persistence storage.
241
+ *
206
242
* @return {* }
207
243
*/
208
244
getInputFieldEmailValue : function ( ) {
@@ -212,6 +248,8 @@ define([
212
248
} ,
213
249
214
250
/**
251
+ * Setting the email input field value pulled from persistence storage.
252
+ *
215
253
* @param {String } email
216
254
*/
217
255
setInputFieldEmailValue : function ( email ) {
0 commit comments