2015-10-06 18:50:44 +00:00
|
|
|
jQuery(function(a){function b(){d&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(){a.ajax(f)}if("undefined"==typeof wc_cart_fragments_params)return!1;var d;try{d="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc")}catch(e){d=!1}var f={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(c){c&&c.fragments&&(a.each(c.fragments,function(b,c){a(b).replaceWith(c)}),d&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(c.fragments)),sessionStorage.setItem("wc_cart_hash",c.cart_hash),c.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(d){var g=null,h=864e5;a(document.body).bind("added_to_cart",function(a,c,d){var e=sessionStorage.getItem("wc_cart_hash");(null===e||void 0===e||""===e)&&b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(c)),sessionStorage.setItem("wc_cart_hash",d)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(g),g=setTimeout(c,h)});try{var i=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),j=sessionStorage.getItem("wc_cart_hash"),k=a.cookie("woocommerce_cart_hash"),l=sessionStorage.getItem("wc_cart_created");if((null===j||void 0===j||""===j)&&(j=""),(null===k||void 0===k||""===k)&&(k=""),j&&(null===l||void 0===l||""===l))throw"No cart_created";if(l){var m=1*l+h,n=(new Date).getTime();if(n>m)throw"Fragment expired";g=setTimeout(c,m-n)}if(!i||!i["div.widget_shopping_cart_content"]||j!==k)throw"No fragment";a.each(i,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(e){c()}}else c();a.cookie("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});
|