1// source --> https://offshoreportstjohns.com/wp-content/plugins/currency-per-product-for-woocommerce/assets/js/fix_cart_fragments.js?ver=2.0.0 2/* global wc_cart_fragments_params, fix_cart_fragments_params */ 3jQuery( function ( $ ) { 4 5 // Check if Session Storage is available in the browser. 6 let is_session_storage_available = true; 7 8 try { 9 is_session_storage_available = ( 'sessionStorage' in window && window.sessionStorage !== null ); 10 window.sessionStorage.setItem( 'alg-wc-cpp', 'test' ); 11 window.sessionStorage.removeItem( 'alg-wc-cpp' ); 12 } catch (err) { 13 is_session_storage_available = false; 14 } 15 16 if ( typeof wc_cart_fragments_params != 'undefined' ) { 17 18 let cart_hash_key = wc_cart_fragments_params.cart_hash_key; 19 let fragments = wc_cart_fragments_params.fragment_name; 20 21 if ( is_session_storage_available ) { 22 $( document ).ready( function () { 23 24 if ( fix_cart_fragments_params.do_run === 'yes' ) { 25 let fragmentObj = JSON.parse( sessionStorage.getItem( fragments ) ); 26 27 if (fragmentObj && fragmentObj["a.cart-contents"]) { 28 let cart_contents = fragmentObj["a.cart-contents"]; 29 let currency = '&' + fix_cart_fragments_params.currency_symbol; 30 31 if ( ! cart_contents.includes( currency ) ) { 32 sessionStorage.removeItem( cart_hash_key ); 33 sessionStorage.removeItem( fragments ); 34 $( document.body ).trigger( 'wc_fragment_refresh' ); 35 } 36 } 37 } else if ( fix_cart_fragments_params.do_run == 'no' ) { 38 // Page here is checkout page. So reset whatever we did for Product Page and Cart Page. 39 sessionStorage.removeItem( cart_hash_key ); 40 sessionStorage.removeItem( fragments ); 41 $( document.body ).trigger( 'wc_fragment_refresh' ); 42 } 43 }); 44 } 45 } 46});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.