관리-도구
편집 파일: cart-fragments.min.js
jQuery(function(r){if("undefined"==typeof kkart_cart_fragments_params)return!1;var t=!0,o=kkart_cart_fragments_params.cart_hash_key;try{t="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("kkart","test"),window.sessionStorage.removeItem("kkart"),window.localStorage.setItem("kkart","test"),window.localStorage.removeItem("kkart")}catch(w){t=!1}function a(){t&&sessionStorage.setItem("kkart_cart_created",(new Date).getTime())}function s(e){t&&(localStorage.setItem(o,e),sessionStorage.setItem(o,e))}var e={url:kkart_cart_fragments_params.kkart_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",data:{time:(new Date).getTime()},timeout:kkart_cart_fragments_params.request_timeout,success:function(e){e&&e.fragments&&(r.each(e.fragments,function(e,t){r(e).replaceWith(t)}),t&&(sessionStorage.setItem(kkart_cart_fragments_params.fragment_name,JSON.stringify(e.fragments)),s(e.cart_hash),e.cart_hash&&a()),r(document.body).trigger("kkart_fragments_refreshed"))},error:function(){r(document.body).trigger("kkart_fragments_ajax_error")}};function n(){r.ajax(e)}if(t){var i=null;r(document.body).on("kkart_fragment_refresh updated_kkart_div",function(){n()}),r(document.body).on("added_to_cart removed_from_cart",function(e,t,r){var n=sessionStorage.getItem(o);null!==n&&n!==undefined&&""!==n||a(),sessionStorage.setItem(kkart_cart_fragments_params.fragment_name,JSON.stringify(t)),s(r)}),r(document.body).on("kkart_fragments_refreshed",function(){clearTimeout(i),i=setTimeout(n,864e5)}),r(window).on("storage onstorage",function(e){o===e.originalEvent.key&&localStorage.getItem(o)!==sessionStorage.getItem(o)&&n()}),r(window).on("pageshow",function(e){e.originalEvent.persisted&&(r(".widget_shopping_cart_content").empty(),r(document.body).trigger("kkart_fragment_refresh"))});try{var c=JSON.parse(sessionStorage.getItem(kkart_cart_fragments_params.fragment_name)),_=sessionStorage.getItem(o),g=Cookies.get("kkart_cart_hash"),m=sessionStorage.getItem("kkart_cart_created");if(null!==_&&_!==undefined&&""!==_||(_=""),null!==g&&g!==undefined&&""!==g||(g=""),_&&(null===m||m===undefined||""===m))throw"No cart_created";if(m){var d=+m+864e5,m=(new Date).getTime();if(d<m)throw"Fragment expired";i=setTimeout(n,d-m)}if(!c||!c["div.widget_shopping_cart_content"]||_!==g)throw"No fragment";r.each(c,function(e,t){r(e).replaceWith(t)}),r(document.body).trigger("kkart_fragments_loaded")}catch(w){n()}}else n();0<Cookies.get("kkart_items_in_cart")?r(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():r(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),r(document.body).on("adding_to_cart",function(){r(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()}),"undefined"!=typeof wp&&wp.customize&&wp.customize.selectiveRefresh&&wp.customize.widgetsPreview&&wp.customize.widgetsPreview.WidgetPartial&&wp.customize.selectiveRefresh.bind("partial-content-rendered",function(){n()})});