1
+ /* global wc_cart_fragments_params */
1
2
jQuery ( function ( $ ) {
2
3
3
4
// wc_cart_fragments_params is required to continue, ensure the object exists
4
5
if ( typeof wc_cart_fragments_params === 'undefined' ) {
5
6
return false ;
6
7
}
7
8
8
- /** Cart Handling */
9
+ /* Storage Handling */
10
+ var $supports_html5_storage ;
9
11
try {
10
12
$supports_html5_storage = ( 'sessionStorage' in window && window . sessionStorage !== null ) ;
11
13
@@ -15,7 +17,7 @@ jQuery( function( $ ) {
15
17
$supports_html5_storage = false ;
16
18
}
17
19
18
- $fragment_refresh = {
20
+ var $fragment_refresh = {
19
21
url : wc_cart_fragments_params . wc_ajax_url + 'get_refreshed_fragments' ,
20
22
type : 'POST' ,
21
23
success : function ( data ) {
@@ -35,6 +37,7 @@ jQuery( function( $ ) {
35
37
}
36
38
} ;
37
39
40
+ /* Cart Handling */
38
41
if ( $supports_html5_storage ) {
39
42
40
43
$ ( document . body ) . bind ( 'added_to_cart' , function ( event , fragments , cart_hash ) {
@@ -55,14 +58,13 @@ jQuery( function( $ ) {
55
58
cookie_hash = '' ;
56
59
}
57
60
58
- if ( wc_fragments && wc_fragments [ 'div.widget_shopping_cart_content' ] && cart_hash == cookie_hash ) {
61
+ if ( wc_fragments && wc_fragments [ 'div.widget_shopping_cart_content' ] && cart_hash === cookie_hash ) {
59
62
60
63
$ . each ( wc_fragments , function ( key , value ) {
61
64
$ ( key ) . replaceWith ( value ) ;
62
65
} ) ;
63
66
64
67
$ ( document . body ) . trigger ( 'wc_fragments_loaded' ) ;
65
-
66
68
} else {
67
69
throw 'No fragment' ;
68
70
}
@@ -75,7 +77,7 @@ jQuery( function( $ ) {
75
77
$ . ajax ( $fragment_refresh ) ;
76
78
}
77
79
78
- /* Cart hiding */
80
+ /* Cart Hiding */
79
81
if ( $ . cookie ( 'woocommerce_items_in_cart' ) > 0 ) {
80
82
$ ( '.hide_cart_widget_if_empty' ) . closest ( '.widget_shopping_cart' ) . show ( ) ;
81
83
} else {
@@ -84,6 +86,5 @@ jQuery( function( $ ) {
84
86
85
87
$ ( document . body ) . bind ( 'adding_to_cart' , function ( ) {
86
88
$ ( '.hide_cart_widget_if_empty' ) . closest ( '.widget_shopping_cart' ) . show ( ) ;
87
- } ) ;
88
-
89
+ } ) ;
89
90
} ) ;
0 commit comments