10
10
*/
11
11
define ( [
12
12
'jquery' ,
13
- 'Magento_Customer/js/customer-data'
13
+ 'Magento_Customer/js/customer-data' ,
14
+ 'jquery/jquery-storageapi'
14
15
] , function ( $ , storage ) {
15
16
'use strict' ;
16
17
@@ -30,20 +31,27 @@ define([
30
31
var data = storage . get ( cacheKey ) ( ) ;
31
32
32
33
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
+ }
44
39
}
45
40
46
41
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
+ }
47
55
} ;
48
56
49
57
return {
0 commit comments