-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_to_cart.min.js
161 lines (157 loc) · 38.1 KB
/
add_to_cart.min.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Name: Blogger Add To Cart Plugin
// Author: VUTHANH
if (document.getElementById("plugin-custom") && $("li.html").hasClass("widget_shopping_cart") && $("#post-id").attr("data-blogid") == blogId) {
var cart_item, cart_item_total, cart_html, id_sp, url_sp, ten_sp, anh_sp, sl_sp, gia_sp, thanh_tien, remove_item, total_product, count, counter, slsp, subtotal, thanh_tien_update, tam_tinh, phi_ship, shipping_table, message_wrapper = "",
cart_empty_page = '<div class="text-center pt pb"><div class="woocommerce-notices-wrapper"></div><p class="cart-empty">' + cart.emptypage + '</p><p class="return-to-shop"><a class="button primary wc-backward" href=' + pageConf.shopurl + ' title="' + cart.storepage + '">' + cart.storepage + "</a></p></div>";
$(document).ready(function() {
var e, t = [],
a = "<a href=" + cart.url + ' class="button wc-forward">' + cart.view + "</a>",
o = "<a href=" + checkout.url + ' class="button checkout wc-forward">' + checkout.view + "</a>",
s = '<p class="woocommerce-mini-cart__empty-message">' + cart.empty + "</p>";
function r(s) {
s.preventDefault();
var r = $(this);
function c() {
$.ajax({
type: "GET",
url: "/feeds/posts/default/" + id_sp,
data: { alt: "json-in-script" },
dataType: "jsonp",
success: function(t) {
if (t.entry) {
for (var s = t.entry, c = 0; c < s.link.length; c++)
if ("alternate" == s.link[c].rel) { url_sp = s.link[c].href; break }
"category" in s && (gia_sp = s.category[0].term), "media$thumbnail" in s ? anh_sp = s.media$thumbnail.url.replace("s72-c", "s76") : "enclosure" == s.link[0].rel && ("image/png" != s.link[0].type && "image/jpg" != s.link[0].type && "image/jpeg" != s.link[0].type || (anh_sp = s.link[0].href)), ten_sp = s.title.$t, void 0 === (sl_sp = r.parent().find("input.input-text").val()) && (sl_sp = 1), thanh_tien = sl_sp * gia_sp, null != localStorage.getItem("saved_data") ? (thanh_tien_update = $("#post-id").attr("data-product-total"), tam_tinh = Number(thanh_tien) + Number(thanh_tien_update)) : tam_tinh = thanh_tien, remove_item = cart.url + "?remove_item=" + id_sp, cart_item = '<li class="woocommerce-mini-cart-item mini_cart_item" data-product-id=' + id_sp + "><a href=" + remove_item + ' class="remove remove_item_from_cart" title="Remove this item">×</a><a href=' + url_sp + ' title="' + ten_sp + '"><img src=' + anh_sp + ' alt="' + ten_sp + '">' + ten_sp + '</a><span class="quantity"><label class="sl">' + sl_sp + '</label> × <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-amount amount"><label class="gia">' + curr(gia_sp, ".", ",") + '</label><span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span></li>", null === localStorage.getItem("saved_data") && (total_product = '<ul class="woocommerce-mini-cart cart_list product_list_widget"></ul><p class="woocommerce-mini-cart__total total"><strong>' + cart.subtotal + ': </strong><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currency"></span><span class="woocommerce-Price-currencySymbol">' + dv_tt + '</span></span></p><p class="woocommerce-mini-cart__buttons buttons">' + a + o + "</p>"), $(".widget_shopping_cart_content").html(total_product), cart_item_total = $(".woocommerce-mini-cart"), $(cart_item).appendTo(cart_item_total), count = Number($("i.icon-shopping-basket").attr("data-icon-label")), sub = document.querySelector(".woocommerce-mini-cart__total .woocommerce-Price-currency"), $("i.icon-shopping-basket").attr("data-icon-label", count + 1), $("#post-id").attr({ "data-product-added": count + 1, "data-product-total": tam_tinh }).append("<li id=" + id_sp + " data-product-id=" + id_sp + " data-product-quantity=" + sl_sp + " data-product-price=" + gia_sp + "></li>"), sub.innerHTML = curr(tam_tinh, ".", ","), e = $(".data-products-list").html(), count = $("i.icon-shopping-basket").attr("data-icon-label"), localStorage.setItem("saved_counter", count), cart_html = $(".widget_shopping_cart_content").html(), localStorage.setItem("luu_ten_sp", ten_sp), localStorage.setItem("saved_data", cart_html), localStorage.setItem("postid_added", e), location.reload(), $(window).scrollTop(0)
}
}
})
}
if (r.addClass("loading"), id_sp = this.value, null != localStorage.getItem("saved_data")) {
tam_tinh = Number($("#post-id").attr("data-product-total")), count = $("#post-id").attr("data-product-added");
for (var l = $("#post-id>li"), i = $(".widget_shopping_cart ul.product_list_widget li"), n = 0; n < l.length; n++) t.push(l[n].id);
if ($(i).each(function(a) {
var o = $(this),
s = o.attr("data-product-id");
if (t.includes(id_sp) && s == id_sp) {
a = o.index();
var r = $(i[a]).find("label.sl").html();
void 0 === sl_sp && (sl_sp = 1), r = Number(sl_sp) + Number(r), $(i[a]).find("label.sl").html(r), gia_sp = Number($(i[a]).find("label.gia").html().replace(/,/gi, "")), thanh_tien = sl_sp * gia_sp, tam_tinh += Number(thanh_tien), sub = document.querySelector(".woocommerce-mini-cart__total .woocommerce-Price-currency"), sub.innerHTML = curr(tam_tinh, ".", ","), $(l[a]).attr("data-product-quantity", r), $("#post-id").attr("data-product-total", tam_tinh), e = $(".data-products-list").html(), cart_html = $(".widget_shopping_cart_content").html(), localStorage.setItem("luu_ten_sp", ten_sp), localStorage.setItem("saved_data", cart_html), localStorage.setItem("postid_added", e), location.reload(), $(window).scrollTop(0)
}
}), !t.includes(id_sp) && count >= cart.item) {
var m = '<div class="show" id="modal--confirm"><div class="modal--dialog"><div class="_3em"></div><div class="modal--content"><div class="modal--header flex align-center"><div class="_mht">' + messages.alert + '</div><div class="_mhc modal--close"><svg viewBox="0 0 24 24"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg></div></div><div class="modal--body"><div><p>' + cart.alert + '</p></div></div><div class="modal--footer"><button class="modal--close" type="button">' + messages.calcel + '</button><button class="modal--submit" type="submit">' + messages.accept + '</button></div></div><div class="_3em"></div></div></div>';
$(m).appendTo("body"), $("html").css("overflow", "hidden"), $(".modal--submit").click(function() { location.href = checkout.url }), $(".modal--close").click(function() { $("html").removeAttr("style"), $("#modal--confirm").remove(), $(".loading").removeClass("loading") })
} else c()
} else c()
}
if ($(".single_add_to_cart_button").on("click", r), $(".quick-view-added").on("click", function(e) {
e.preventDefault(), $(this).parent().parent().addClass("processing");
var t = $(this).attr("data-id");
$.ajax({
type: "GET",
url: "/feeds/posts/default/" + t,
data: { alt: "json-in-script" },
dataType: "jsonp",
success: function(e) {
if ($(".processing").removeClass("processing"), e.entry) {
for (var t = "", a = "", o = "", s = "", c = e.entry, l = c.id.$t.replace("tag:blogger.com,1999:blog-" + blogId + ".post-", ""), i = c.title.$t, n = 0; n < c.link.length; n++)
if ("alternate" == c.link[n].rel) { var m = c.link[n].href; break }
for (var d = 0; d < c.link.length; d++) "enclosure" == c.link[d].rel && ("image/png" != c.link[d].type && "image/jpg" != c.link[d].type && "image/jpeg" != c.link[d].type || (t += '<div class="slide"><img alt="' + i + '" src=' + c.link[d].href + "></div>"));
if ("media$thumbnail" in c) var p = c.media$thumbnail.url.replace("s72-c", "s1600");
else {
var u = c.content.$t,
_ = u.indexOf("<img"),
g = u.indexOf('src="', _),
h = u.indexOf('"', g + 5),
v = u.substr(g + 5, h - g - 5);
p = -1 != _ && -1 != g && -1 != h && "" != v ? v : thumbnail_url
}
if ("category" in c)
for (var b = curr(c.category[0].term, ".", ","), w = curr(c.category[1].term, ".", ","), f = "", y = "", S = 1; S < c.category.length; S++) {
var k = (y += c.category[S].term).indexOf(strn),
I = y.indexOf(strm),
P = y.indexOf(stock),
x = y.slice(k, Number(k) + strn.length),
C = y.slice(I, Number(I) + strm.length),
N = y.slice(P, Number(P) + stock.length),
T = c.category[1].term;
T != w ? [strs, strn, strm, strh, stock, T].includes(c.category[S].term) || (f += '<a href="/search/label/' + c.category[S].term + "?max-results=" + pageConf.numposts + '" rel="tag" title="' + c.category[S].term + '">' + c.category[S].term + "</a>") : [strs, strn, strm, strh, stock].includes(c.category[S].term) || (f += '<a href="/search/label/' + c.category[S].term + "?max-results=" + pageConf.numposts + '" rel="tag" title="' + c.category[S].term + '">' + c.category[S].term + "</a>")
}
if ("content" in c) {
var D, q = (D = c.content.$t).lastIndexOf("<a name='more'></a>");
if (q) var L = D.substring(0, Number(q));
else(D = D.replace(/<\S[^>]*>/g, "")).length < snippets || (L = (D = D.substring(0, snippets)).substring(0, D.lastIndexOf(" ")))
} else L = "";
var M = '<div class="slider product-gallery-slider mb-0 flickity-enabled is-draggable"><div class="slide first"><img alt="' + i + '" src=' + p + "></div>" + t + "</div>";
o = '<div class="price-wrapper"><p class="price product-page-price"><span class="woocommerce-Price-amount amount">' + b + '</span><span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></p></div>", x === strn && C === strm ? (a = '<div class="callout badge badge-circle"><div class="badge-inner secondary on-sale"><span class="onsale">Sale!</span></div></div><div class="badge callout badge-circle"><div class="badge-inner callout-new-bg is-small new-bubble">New</div></div>', o = '<div class="price-wrapper"><p class="price product-page-price price-on-sale"><del><span class="woocommerce-Price-amount amount">' + w + '<span class="woocommerce-Price-currencySymbol">' + dv_tt + '</span></span></del><ins><span class="woocommerce-Price-amount amount">' + b + '</span><span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></ins></p></div>") : x === strn ? (a = '<div class="callout badge badge-circle"><div class="badge-inner secondary on-sale"><span class="onsale">Sale!</span></div></div>', o = '<div class="price-wrapper"><p class="price product-page-price price-on-sale"><del><span class="woocommerce-Price-amount amount">' + w + '<span class="woocommerce-Price-currencySymbol">' + dv_tt + '</span></span></del><ins><span class="woocommerce-Price-amount amount">' + b + '</span><span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></ins></p></div>") : C === strm && (a = '<div class="badge callout badge-circle"><div class="badge-inner callout-new-bg is-small new-bubble">New</div></div>'), s = N == stock ? '<div class="product-lightbox lightbox-content"><div class="product-quick-view-container"><div class="row row-collapse mb-0 product"><div class="product-gallery large-6 col">' + M + '<div class="badge-container is-larger absolute left top z-1">' + a + '</div></div><div class="product-info summary large-6 col entry-summary"><div class="product-lightbox-inner"><a class="plain" href=' + m + ' title="' + i + '"><h2>' + i + '</h2></a><div class="is-divider small"></div>' + o + '<div class="product-short-description">' + L + '</div><div class="product-unavailable"><p class="out-of-stock"><strong>' + messages.stock + '</strong></p></div><div class="product_meta"><span class="posted_in tags">Categories: ' + f + "</span></div></div></div></div></div>" : '<div class="product-lightbox lightbox-content"><div class="product-quick-view-container"><div class="row row-collapse mb-0 product"><div class="product-gallery large-6 col">' + M + '<div class="badge-container is-larger absolute left top z-1">' + a + '</div></div><div class="product-info summary large-6 col entry-summary"><div class="product-lightbox-inner"><a class="plain" href=' + m + ' title="' + i + '"><h2>' + i + '</h2></a><div class="is-divider small"></div>' + o + '<div class="product-short-description">' + L + '</div><form class="cart">' + quantity + '<button aria-label="' + cart.add + '" class="single_add_to_cart_button button alt" name="' + i + '" type="submit" value="' + l + '">' + cart.add + '</button></form><div class="product_meta"><span class="posted_in tags">Categories: ' + f + "</span></div></div></div></div></div>", $.magnificPopup.open({ removalDelay: 300, closeBtnInside: !0, autoFocusLast: !1, items: { src: s, type: "inline" } }), $(".product-gallery-slider").flickity({ autoPlay: 3e3, imagesLoaded: !0, pauseAutoPlayOnHover: !0 }, "resize"), $(".single_add_to_cart_button").on("click", r)
}
}
})
}), (ten_sp = localStorage.getItem("luu_ten_sp")) && ($(".cart-item.has-dropdown").addClass("current-dropdown"), message_wrapper = '<div class="woocommerce-message message-wrapper" role="alert"><div class="message-container container success-color medium-text-center"><i class="icon-checkmark"></i> “' + ten_sp + "” " + cart.success + "</div></div>", $(message_wrapper).insertBefore($("main#main")), setTimeout(function() { $(".message-wrapper").remove() }, 3e3), localStorage.removeItem("luu_ten_sp")), local_data = localStorage.getItem("saved_data")) {
(e = localStorage.getItem("postid_added")) && $(".data-products-list").html(e), $(".widget_shopping_cart_content").html(local_data), subtotal = Number($("#post-id").attr("data-product-total")), counter = localStorage.getItem("saved_counter"), $("tr.cart-subtotal>td>.woocommerce-Price-amount").html(curr(subtotal, ".", ",")), $("i.icon-shopping-basket").attr("data-icon-label", counter);
var c, l, i, n, m, d, p, u, _, g, h, v, b = "",
w = "",
f = "",
y = $(".widget_shopping_cart ul.product_list_widget li"),
S = $("#post-id>li");
function k() { "" != d && ($(".payment_methods li.woocommerce-notice").remove(), $(".payment_methods li.for_cash,.payment_methods li.for_bank_transfer").show()) }
if ($(y).each(function(t) {
var a = $(this),
o = a.find("a:nth-of-type(1)");
remove_item = a.find("a:nth-of-type(1)").attr("href"), url_sp = a.find("a:nth-of-type(2)").attr("href"), ten_sp = a.find("a:nth-of-type(2)").attr("title"), anh_sp = a.find("a:nth-of-type(2) img").attr("src"), sl_sp = a.find("label.sl").html(), gia_sp = a.find("label.gia").html().replace(/,/gi, ""), thanh_tien = sl_sp * gia_sp, c += '<tr class="cart_item"><td class="product-remove"><a href=' + remove_item + ' class="remove" aria-label="Remove this item">×</a></td><td class="product-thumbnail"><a href=' + url_sp + '><img alt="' + ten_sp + '" src=' + anh_sp + '></a></td><td class="product-name" data-title="Product"><a href=' + url_sp + ">" + ten_sp + '</a><div class="show-for-small mobile-product-price"><span class="mobile-product-price__qty">' + sl_sp + ' x </span><span class="woocommerce-Price-amount amount">' + curr(gia_sp, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + '</span></div></td><td class="product-price" data-title="Price"><span class="woocommerce-Price-amount amount">' + curr(gia_sp, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + '</span></td><td class="product-quantity" data-title="Quantity"><div class="quantity buttons_added"><input type="button" value="-" class="minus button is-form"><input class="input-text qty text" max="9999" min="0" inputmode="numeric" name="quantity" pattern="[0-9]*" size="4" type="number" value=' + sl_sp + '><input type="button" value="+" class="plus button is-form"></div></td><td class="product-subtotal" data-title="Total"><span class="woocommerce-Price-amount amount">' + curr(thanh_tien, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span></td></tr>", l += '<tr class="cart_item"><td class="product-name">' + ten_sp + ' <strong class="product-quantity">× ' + sl_sp + '</strong></td><td class="product-total"><span class="woocommerce-Price-amount amount">' + curr(thanh_tien, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span></td></tr>", w += '<tr class="woocommerce-table__line-item order_item"><td class="woocommerce-table__product-name product-name"><a href=' + url_sp + ' title="' + ten_sp + '">' + ten_sp + '</a><strong class="product-quantity"> × ' + sl_sp + '</strong></td><td class="woocommerce-table__product-total product-total"><span class="woocommerce-Price-amount amount">' + curr(thanh_tien, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span></td></tr>", b += ten_sp + " x " + sl_sp + " x " + curr(gia_sp, ".", ",") + dv_tt + " = " + curr(thanh_tien, ".", ",") + dv_tt + "\n", $(".woocommerce-cart-form").find("tbody").html(c), $("table.woocommerce-table>tbody").html(w), $(".woocommerce-checkout-review-order-table>tbody").html(l), $("table.woocommerce-table>tfoot>tr.order-subtotal>td").html('<span class="woocommerce-Price-amount amount">' + curr(subtotal, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span"), $(".woocommerce-checkout-review-order-table>tfoot>tr.cart-subtotal>td").html('<span class="woocommerce-Price-amount amount">' + curr(subtotal, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span>"), $(o).click(function(a) {
a.preventDefault();
var o = $(this);
t = o.parent().index(), id_sp = $(S[t]).attr("id"), o.parent().addClass("processing"), slsp = Number($("i.icon-shopping-basket").attr("data-icon-label")), setTimeout(function() { slsp > 1 ? (sl_sp = Number(o.parent().find(".sl").html()), gia_sp = Number(o.parent().find(".gia").html().replace(/,/gi, "")), subtotal -= thanh_tien = sl_sp * gia_sp, $(".woocommerce-Price-currency").html(curr(subtotal, ".", ",")), o.parent().remove(), $(S[t]).remove(), cart_html = $(".widget_shopping_cart_content").html(), $("i.icon-shopping-basket").attr("data-icon-label", slsp - 1), $("#post-id").attr({ "data-product-total": subtotal, "data-product-added": slsp - 1 }), count = Number($("i.icon-shopping-basket").attr("data-icon-label")), localStorage.setItem("saved_data", cart_html), localStorage.setItem("saved_counter", count), $('.single_add_to_cart_button[value="' + id_sp + '"]').removeAttr("disabled").html(cart.add), e = $(".data-products-list").html(), localStorage.setItem("postid_added", e)) : ($("i.icon-shopping-basket").attr("data-icon-label", 0), $(".widget_shopping_cart_content").html(s), $(".single_add_to_cart_button").removeAttr("disabled").html(cart.add), localStorage.removeItem("saved_data"), localStorage.removeItem("postid_added"), sessionStorage.removeItem("coupon_saved")), $(".processing").removeClass("processing") }, 500)
});
var r = $("tr.cart_item");
$(r).each(function(a) {
var o, c, l, i = $(this).find("td.product-remove a"),
n = $(this).find(".button.is-form"),
m = $(this).find("input.input-text"),
d = $(this).parent().parent().find("button[name=update_cart]");
$(i).click(function(a) {
a.preventDefault();
var o = $(this);
t = o.parent().parent().index(), $(".woocommerce-cart-form").addClass("processing"), slsp = Number($("i.icon-shopping-basket").attr("data-icon-label")), gia_sp = Number($(y[t]).find(".gia").html().replace(/,/gi, "")), setTimeout(function() { location.reload(), $(window).scrollTop(0), slsp > 1 ? (sl_sp = Number($(y[t]).find(".sl").html()), subtotal -= thanh_tien = sl_sp * gia_sp, $(".woocommerce-Price-currency").html(curr(subtotal, ".", ",")), $(y[t]).remove(), $(r[t]).remove(), $(S[t]).remove(), cart_html = $(".widget_shopping_cart_content").html(), localStorage.setItem("saved_data", cart_html), $("i.icon-shopping-basket").attr("data-icon-label", slsp - 1), $("#post-id").attr({ "data-product-total": subtotal, "data-product-added": slsp - 1 }), count = Number($("i.icon-shopping-basket").attr("data-icon-label")), localStorage.setItem("saved_counter", count), e = $(".data-products-list").html(), localStorage.setItem("postid_added", e)) : ($("i.icon-shopping-basket").attr("data-icon-label", 0), $(".widget_shopping_cart_content").html(s), $(".single_add_to_cart_button").removeAttr("disabled").html(cart.add), localStorage.removeItem("saved_data"), localStorage.removeItem("postid_added"), sessionStorage.removeItem("coupon_saved")) }, 1e3)
}), $(n).one("click", function() { $(d).removeAttr("disabled") }), $(n).on("click", function() {
o = Number($(m).attr("value")), $(this).hasClass("minus") ? (sl_sp = Number($(m).val()) - 1, l = Math.abs(sl_sp - o)) : $(this).hasClass("plus") && (sl_sp = Number($(m).val()) + 1, c = sl_sp - o), $(d).click(function(o) {
o.preventDefault(), t = a, gia_sp = Number($(r[t]).find(".woocommerce-Price-amount").html().replace(/,/gi, "")), $(".woocommerce-cart-form").addClass("processing"), setTimeout(function() {
if (sl_sp <= 0)(slsp = Number($("i.icon-shopping-basket").attr("data-icon-label"))) > 1 ? (subtotal -= thanh_tien = 1 * gia_sp, $(".woocommerce-Price-currency").html(curr(subtotal, ".", ",")), $(y[t]).remove(), $(r[t]).remove(), $(S[t]).remove(), $("i.icon-shopping-basket").attr("data-icon-label", slsp - 1), $("#post-id").attr({ "data-product-total": subtotal, "data-product-added": slsp - 1 }), count = Number($("i.icon-shopping-basket").attr("data-icon-label")), localStorage.setItem("saved_counter", count), e = $(".data-products-list").html(), cart_html = $(".widget_shopping_cart_content").html(), localStorage.setItem("saved_data", cart_html), localStorage.setItem("postid_added", e)) : ($("i.icon-shopping-basket").attr("data-icon-label", 0), $(".widget_shopping_cart_content").html(s), $(".single_add_to_cart_button").removeAttr("disabled").html(cart.add), localStorage.removeItem("saved_data"), localStorage.removeItem("postid_added"));
else {
var a = "";
a = c >= 1 ? subtotal + (thanh_tien = c * gia_sp) : subtotal - (thanh_tien = l * gia_sp), $(y[t]).find(".sl").html(sl_sp), $(S[t]).attr("data-product-quantity", sl_sp), $("#post-id").attr("data-product-total", a), $(".woocommerce-Price-currency").html(curr(a, ".", ",")), e = $(".data-products-list").html(), cart_html = $(".widget_shopping_cart_content").html(), localStorage.setItem("saved_data", cart_html), localStorage.setItem("postid_added", e)
}
location.reload(), $(window).scrollTop(0)
}, 1e3)
})
})
})
}), (phi_ship = localStorage.getItem("luu_phi_ship")) && ($(".shipping-calculator-button").html(cart.address), $(".shipping__table>tbody>tr>td>span").html('<span class="woocommerce-Price-amount amount">' + curr(phi_ship, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span>"), $("table.woocommerce-table>tfoot>tr.order-shipping>td").html('<span class="woocommerce-Price-amount amount">' + curr(phi_ship, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span>")), (shipping_table = localStorage.getItem("shipping_table_saved")) && $(".cart_totals .shipping__table").html(shipping_table), (i = localStorage.getItem("billing_name_saved")) && $("#billing_name").attr({ placeholder: i, value: i }), (n = localStorage.getItem("billing_phone_saved")) && $("#billing_phone").attr({ placeholder: n, value: n }), (m = localStorage.getItem("billing_email_saved")) && $("#billing_email").attr({ placeholder: m, value: m }), (d = localStorage.getItem("address_1_saved")) && ($('select[name="calc_shipping_country"] option').each(function() { $(this).text() == d && $(this).attr("selected", "") }), $("#billing_address_1").attr("value", d), k()), (p = localStorage.getItem("address_2_saved")) && $("#billing_address_2").attr({ placeholder: p, value: p }), (u = localStorage.getItem("address_3_saved")) && $("#billing_address_3").attr({ placeholder: u, value: u }), (_ = localStorage.getItem("address_4_saved")) && $("#billing_address_4").attr({ placeholder: _, value: _ }), (g = localStorage.getItem("order_comments_saved")) && $("#order_comments").attr("placeholder", g).html(g), $("#billing_name").keyup(function() { i = $(this).val(), localStorage.setItem("billing_name_saved", i) }), $("#billing_phone").keyup(function() { n = $(this).val(), localStorage.setItem("billing_phone_saved", n) }), $("#billing_email").keyup(function() { m = $(this).val(), localStorage.setItem("billing_email_saved", m) }), $("select[name=calc_shipping_country]").change(function() { d = $(this).children("option:selected").val(), phi_ship = kv1.includes(d) ? phikv1 : phi_ship = kv2.includes(d) ? phikv2 : phi_ship = kv3.includes(d) ? phikv3 : phi_vc, $(".woocommerce-checkout-review-order-table,.woocommerce-checkout-payment").addClass("processing"), h = subtotal + Number(phi_ship), localStorage.setItem("luu_phi_ship", phi_ship), localStorage.setItem("address_1_saved", d), localStorage.setItem("payment_saved", h), setTimeout(function() { $("#billing_address_1").attr("value", d), $(".processing").removeClass("processing"), $(".shipping__table>tbody>tr>td>span").html('<span class="woocommerce-Price-amount amount">' + curr(phi_ship, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span>"), $("tr.order-total>td>.woocommerce-Price-amount").html(curr(h, ".", ",")), $("input#shipping_price").attr("value", curr(phi_ship, ".", ",") + dv_tt), k() }, 500) }), $("#billing_address_2").keyup(function() { p = $(this).val(), localStorage.setItem("address_2_saved", p) }), $("#billing_address_3").keyup(function() { u = $(this).val(), localStorage.setItem("address_3_saved", u) }), $("#billing_address_4").keyup(function() { _ = $(this).val(), localStorage.setItem("address_4_saved", _) }), $("#order_comments").keyup(function() { g = $(this).val(), localStorage.setItem("order_comments_saved", g) }), $("form[name=shipping]").on("submit", function(e) {
e.preventDefault();
var t = $(this);
$(".cart_totals .shipping__table").addClass("processing"), setTimeout(function() { $(".woocommerce-invalid").removeClass("woocommerce-invalid"), $(".processing").removeClass("processing"), t.parent().find("span").html('<span class="woocommerce-Price-amount amount">' + curr(phi_ship, ".", ",") + '</span><span class="woocommerce-Price-currencySymbol amount">' + dv_tt + "</span"), t.find(".shipping-calculator-button").html(cart.address), t.find(".shipping-calculator-form").hide(), $("tr.order-total>td>.woocommerce-Price-amount").html(curr(h, ".", ",")), shipping_table = $(".cart_totals .shipping__table").html(), localStorage.setItem("shipping_table_saved", shipping_table) }, 500)
}), subtotal >= gt_dh) {
var I = pt_dg,
P = function(e) { for (var t = "", a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", o = 0; o < e; o++) t += a.charAt(Math.floor(Math.random() * a.length)); return t }(10);
$("input#coupon_code").attr({ placeholder: P, value: P }), $(".woocommerce-form-coupon-toggle,form[name=checkout_coupon]").removeClass("hidden"), $("form[name=checkout_coupon]").on("submit", function(e) {
e.preventDefault();
var t = $(this);
f = t.find("input#coupon_code").val(), pt_dg = subtotal * Number(I.replace("%", "")) / 100, sessionStorage.setItem("luu_pt_dg", pt_dg), t.addClass("processing"), setTimeout(function() { f ? (message_wrapper = "vi" == langCof ? '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Mã giảm giá “' + f + "” đã được áp dụng thành công!</div></li></ul>" : '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Coupon “' + f + "” has been successfully applied!</div></li></ul>", t.find("input[type=submit]").attr("disabled", "disabled"), sessionStorage.setItem("coupon_saved", f)) : message_wrapper = "vi" == langCof ? '<ul class="woocommerce-error message-wrapper" role="alert"><li><div class="message-container container alert-color medium-text-center"><span class="message-icon icon-close"></span>Mã giảm giá “' + f + "” không tồn tại!</div></li></ul>" : '<ul class="woocommerce-error message-wrapper" role="alert"><li><div class="message-container container alert-color medium-text-center"><span class="message-icon icon-close"></span>Coupon “' + f + "” does not exist!</div></li></ul>", $(".message-wrapper").remove(), $(message_wrapper).insertBefore($("#blog-posts>.woocommerce")), $(window).scrollTop("slow"), t.removeClass("processing"), sessionStorage.setItem("get_code_saved", P) }, 500)
}), $("form[name=woocommerce-form-coupon]").on("submit", function(e) {
e.preventDefault();
var t = $(this);
f = t.find("input#coupon_code").val(), pt_dg = subtotal * Number(I.replace("%", "")) / 100, v = subtotal - pt_dg + Number(phi_ship), $("tr.coupon-total>td>.woocommerce-Price-amount").html("-" + curr(pt_dg, ".", ",")), $("tr.order-total>td>.woocommerce-Price-amount").html(curr(v, ".", ",")), $("input#coupon_amount").attr("value", curr(pt_dg, ".", ",") + dv_tt), $("input#paymet_total").attr("value", curr(v, ".", ",") + dv_tt), t.addClass("processing"), setTimeout(function() { f ? (message_wrapper = "vi" == langCof ? '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Mã giảm giá “' + f + "” đã được áp dụng thành công!</div></li></ul>" : '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Coupon “' + f + "” has been successfully applied!</div></li></ul>", $(".woocommerce-info.message-wrapper").remove(), t.find("button[type=submit]").attr("disabled", "disabled"), sessionStorage.setItem("coupon_saved", f)) : message_wrapper = "vi" == langCof ? '<ul class="woocommerce-error message-wrapper" role="alert"><li><div class="message-container container alert-color medium-text-center"><span class="message-icon icon-close"></span>Mã giảm giá “' + f + "” không tồn tại!</div></li></ul>" : '<ul class="woocommerce-error message-wrapper" role="alert"><li><div class="message-container container alert-color medium-text-center"><span class="message-icon icon-close"></span>Coupon “' + f + "” does not exist!</div></li></ul>", $(".message-wrapper:not(.woocommerce-info)").remove(), $(message_wrapper).insertBefore(t), t.removeClass("processing"), t.hide(), sessionStorage.setItem("luu_pt_dg", pt_dg), sessionStorage.setItem("get_code_saved", P) }, 500)
})
} else pt_dg = 0, sessionStorage.removeItem("coupon_saved");
(P = sessionStorage.getItem("get_code_saved")) ? (pt_dg = sessionStorage.getItem("luu_pt_dg"), f = sessionStorage.getItem("coupon_saved")) : (pt_dg = 0, f = 0), cart.id != pageId && checkout.id != pageId || (f = sessionStorage.getItem("coupon_saved")) && (message_wrapper = "vi" == langCof ? '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Bạn đã áp dụng mã giảm giá “' + f + "” cho đơn hàng này!</div></li></ul>" : '<ul class="woocommerce-sucess message-wrapper" role="alert"><li><div class="message-container container success-color medium-text-center"><span class="message-icon icon-close"></span>Coupon “' + f + "” has been successfully applied for this order!</div></li></ul>", $(message_wrapper).insertBefore($("#blog-posts>.woocommerce")), $('form[name="checkout_coupon"],form[name="woocommerce-form-coupon"]').addClass("hidden"), $(".woocommerce-info.message-wrapper").remove()), v = subtotal - pt_dg + Number(phi_ship), $("tr.coupon-total>td>.woocommerce-Price-amount").html("-" + curr(pt_dg, ".", ",")), $("tr.order-total>td>.woocommerce-Price-amount").html(curr(v, ".", ",")), $("textarea#order_total").html(b), $("input#sub_total").attr("value", curr(subtotal, ".", ",") + dv_tt), $("input#coupon_amount").attr("value", curr(pt_dg, ".", ",") + dv_tt), $("input#shipping_price").attr("value", curr(phi_ship, ".", ",") + dv_tt), $("table.woocommerce-table>tfoot>tr.order-coupon>td").html('<span class="woocommerce-Price-amount amount">-' + curr(pt_dg, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span>"), $("input#paymet_total").attr("value", curr(v, ".", ",") + dv_tt), $("table.woocommerce-table>tfoot>tr.order-total>td").html('<span class="woocommerce-Price-amount amount">' + curr(v, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + "</span></span>"), "vi" == langCof ? $("ul.woocommerce-order-overview").append('<li class="woocommerce-order-overview__order">Số sản phẩm: <strong>' + counter + '</strong></li><li class="woocommerce-order-overview__date">Ngày: <strong>' + (new Date).getDate() + "/" + ((new Date).getMonth() + 1) + "/" + (new Date).getFullYear() + '</strong></li><li class="woocommerce-order-overview__coupon">Mã giảm giá: <strong>' + f + '</strong></li><li class="woocommerce-order-overview__total total">Tổng cộng: <strong><span class="woocommerce-Price-amount amount">' + curr(v, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + '</span></span></strong></li><li class="woocommerce-order-overview__payment-method method">Phương thức thanh toán: <strong>' + localStorage.getItem("for_payment_saved") + "</strong></li>") : $("ul.woocommerce-order-overview").append('<li class="woocommerce-order-overview__order">Products number: <strong>' + counter + '</strong></li><li class="woocommerce-order-overview__date">Order date: <strong>' + (new Date).getDate() + "/" + ((new Date).getMonth() + 1) + "/" + (new Date).getFullYear() + '</strong></li><li class="woocommerce-order-overview__coupon">Coupon code: <strong>' + f + '</strong></li><li class="woocommerce-order-overview__total total">Total: <strong><span class="woocommerce-Price-amount amount">' + curr(v, ".", ",") + ' <span class="woocommerce-Price-currencySymbol">' + dv_tt + '</span></span></strong></li><li class="woocommerce-order-overview__payment-method method">Payment method: <strong>' + localStorage.getItem("for_payment_saved") + "</strong></li>"), $(".shipping-calculator-button").click(function(e) { e.preventDefault(), $(".shipping-calculator-form").slideToggle("slow") }), $(".message-container a").click(function(e) { e.preventDefault(), $("form[name=woocommerce-form-coupon]").slideToggle("slow") }), $(".validate-required").each(function() {
var e = $(this),
t = e.find("input").attr("value");
$('button[name="calc_shipping"],button[name="woocommerce_checkout_place_order"]').click(function() { "" == t && e.addClass("woocommerce-invalid") })
}), $(".payment_methods li").click(function() {
var e = $(this).find(".payment_box"),
t = $(this).find("input").attr("value");
e.show("slow"), $(".payment_box").not(e).hide(), localStorage.setItem("for_payment_saved", t)
}), setTimeout(function() { $(".processing").removeClass("processing") }, 500), $(".woocommerce-checkout").on("submit", function() { $(this).addClass("processing"), setTimeout(function() { $(".processing").removeClass("processing"), location.href = order.url }, 1e3) })
}
}), cart.id == pageId ? null === localStorage.getItem("saved_data") && $(".woocommerce").html(cart_empty_page) : checkout.id == pageId ? null === localStorage.getItem("saved_data") && (location.href = cart.url) : order.id == pageId && (null != localStorage.getItem("saved_data") ? $(window).unload(function() { localStorage.removeItem("postid_added"), localStorage.removeItem("saved_data"), sessionStorage.removeItem("get_code_saved"), sessionStorage.removeItem("coupon_saved") }) : location.href = cart.url)
}
1