1(function($) { 2 // WooCommerce update fragments fix. 3 $(document).ready(function() { 4 $('body').on('added_to_cart removed_from_cart', function(e, fragments) { 5 if (fragments) { 6 $.each(fragments, function(key, value) { 7 $(key.replace('_wd', '')).replaceWith(value); 8 }); 9 } 10 }); 11 }); 12 13 $('body').on('wc_fragments_refreshed wc_fragments_loaded', function() { 14 if (typeof wd_cart_fragments_params !== 'undefined' && 'undefined' !== typeof Cookies) { 15 var wc_fragments = JSON.parse(sessionStorage.getItem(wd_cart_fragments_params.fragment_name)), 16 cart_hash_key = wd_cart_fragments_params.cart_hash_key, 17 cart_hash = sessionStorage.getItem(cart_hash_key), 18 cookie_hash = Cookies.get('woocommerce_cart_hash'), 19 cart_created = sessionStorage.getItem('wc_cart_created'), 20 day_in_ms = ( 24 * 60 * 60 * 1000 ); 21 22 if (cart_hash === null || cart_hash === undefined || cart_hash === '') { 23 cart_hash = ''; 24 } 25 26 if (cookie_hash === null || cookie_hash === undefined || cookie_hash === '') { 27 cookie_hash = ''; 28 } 29 30 if (cart_hash && (cart_created === null || cart_created === undefined || cart_created === '')) { 31 throw 'No cart_created'; 32 } 33 34 if (cart_created) { 35 var cart_expiration = ((1 * cart_created) + day_in_ms), 36 timestamp_now = (new Date()).getTime(); 37 if (cart_expiration < timestamp_now) { 38 throw 'Fragment expired'; 39 } 40 } 41 42 if (wc_fragments && wc_fragments['div.widget_shopping_cart_content'] && cart_hash === cookie_hash) { 43 $.each(wc_fragments, function(key, value) { 44 $(key.replace('_wd', '')).replaceWith(value); 45 }); 46 } 47 } 48 }); 49})(jQuery);
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.