cart-fragments.min.js
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
jQuery(function (a) {
function b() {
e && sessionStorage.setItem("wc_cart_created", (new Date).getTime())
}
function c(a) {
e && (localStorage.setItem(f, a), sessionStorage.setItem(f, a))
}
function d() {
a.ajax(h)
}
if ("undefined" == typeof wc_cart_fragments_params)return !1;
var e, f = wc_cart_fragments_params.ajax_url.toString() + "-wc_cart_hash";
try {
e = "sessionStorage" in window && null !== window.sessionStorage, window.sessionStorage.setItem("wc", "test"), window.sessionStorage.removeItem("wc"), window.localStorage.setItem("wc", "test"), window.localStorage.removeItem("wc")
} catch (g) {
e = !1
}
var h = {
url: wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%", "get_refreshed_fragments"),
type: "POST",
success: function (d) {
var d={
"fragments":{
"div.widget_shopping_cart_content":"<div class=\"widget_shopping_cart_content\">\n\n<ul class=\"cart_list product_list_widget \">\n\n\t\n\t\t<li class=\"empty\">No products in the cart.<\/li>\n\n\t\n<\/ul><!-- end product list -->\n\n\n<\/div>",
"a.cart-contents":"\t<a class=\"cart-contents\" href=\"https:\/\/www.onepartygo.com\/cart\/\" title=\"View your shopping cart\">\n\t\t\t<\/a>\n"},
"cart_hash":""
}
d && d.fragments && (a.each(d.fragments, function (b, c) {
a(b).replaceWith(c)
}), e && (sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(d.fragments)), c(d.cart_hash), d.cart_hash && b()), a(document.body).trigger("wc_fragments_refreshed"))
}
};
if (e) {
var i = null, j = 864e5;
a(document.body).bind("wc_fragment_refresh updated_wc_div", function () {
d()
}), a(document.body).bind("added_to_cart", function (a, d, e) {
var g = sessionStorage.getItem(f);
null !== g && void 0 !== g && "" !== g || b(), sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(d)), c(e)
}), a(document.body).bind("wc_fragments_refreshed", function () {
clearTimeout(i), i = setTimeout(d, j)
}), a(window).on("storage onstorage", function (a) {
f === a.originalEvent.key && localStorage.getItem(f) !== sessionStorage.getItem(f) && d()
});
try {
var k = a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)), l = sessionStorage.getItem(f), m = a.cookie("woocommerce_cart_hash"), n = sessionStorage.getItem("wc_cart_created");
if (null !== l && void 0 !== l && "" !== l || (l = ""), null !== m && void 0 !== m && "" !== m || (m = ""), l && (null === n || void 0 === n || "" === n))throw"No cart_created";
if (n) {
var o = 1 * n + j, p = (new Date).getTime();
if (o < p)throw"Fragment expired";
i = setTimeout(d, o - p)
}
if (!k || !k["div.widget_shopping_cart_content"] || l !== m)throw"No fragment";
a.each(k, function (b, c) {
a(b).replaceWith(c)
}), a(document.body).trigger("wc_fragments_loaded")
} catch (g) {
d()
}
} else d();
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()
})
});