Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function a(t) {
- t.preventDefault();
- var o = $(this);
- if (o.attr("data-link-event-setted", "yes"), void 0 === o.attr("data-dbclk-prevent") || "yes" != o.attr("data-dbclk-prevent")) {
- o.attr("data-dbclk-prevent", "yes"), setTimeout(function() {
- o.removeAttr("data-dbclk-prevent")
- }, 1e3), $("body").hasClass("t-body_popupshowed") && ($("body").removeClass("t-body_popupshowed"), $(".t-popup").removeClass("t-popup_show"), setTimeout(function() {
- $(".t-popup").not(".t-popup_show").css("display", "none")
- }, 300), tcart__clearProdUrl());
- var r = o.attr("href"),
- a = "0",
- i = "",
- c = "",
- d = "",
- n = "",
- e = "",
- s = "",
- _ = "";
- if ("#order:" == r.substring(0, 7)) {
- var w = r.substring(7);
- if (void 0 !== w && "" != w) {
- if (0 < w.indexOf(":::")) {
- var u = w.indexOf(":::");
- if (0 < w.indexOf("=") && w.indexOf("=") < w.indexOf(":::")) {
- var p = w.substring(u + 3);
- w = w.substring(0, u)
- }
- }
- var l;
- if (0 < w.indexOf("=")) void 0 !== (l = w.split("="))[0] && (i = l[0]), void 0 !== l[1] && (a = l[1]), a = tcart__cleanPrice(a);
- else i = w; if (void 0 !== p && "" != p)
- if (0 < p.indexOf("=")) void 0 !== (l = p.split("="))[0] && void 0 !== l[1] && "" != l[0] && "" != l[1] && "image" == l[0] && 0 < l[1].indexOf("tildacdn.com") && (c = l[1]);
- "" == s && void 0 === (s = o.closest(".r").attr("id").replace("rec", "")) && (s = "")
- }
- }
- var m = $(this).closest(".js-product");
- if (void 0 !== m) {
- if ("" == i && void 0 === (i = m.find(".js-product-name").text()) && (i = ""), "" != a && 0 != a || (a = tcart__cleanPrice(a = m.find(".js-product-price").text())), "" == c)
- if (void 0 !== m.attr("data-product-img") && "" != m.attr("data-product-img")) c = m.attr("data-product-img");
- else {
- var v = m.find(".js-product-img");
- if (void 0 !== v && (v.is("img") && (c = v.attr("src")), v.is("div"))) {
- c = "";
- var y = v.css("background-image");
- void 0 !== y && "" != y && (c = y.replace("url(", "").replace(")", "").replace(/\"/gi, ""))
- }
- }
- "" == n && void 0 === (n = m.attr("data-product-lid")) && (n = ""), "" == e && void 0 === (e = m.attr("data-product-uid")) && (e = ""), "" == s && void 0 === (s = m.closest(".r").attr("id").replace("rec", "")) && (s = ""), "" == _ && void 0 === (_ = m.attr("data-product-inv")) && (_ = "");
- var f = [];
- m.find(".js-product-edition-option").each(function() {
- var t = $(this),
- o = t.find(".js-product-edition-option-name").text(),
- r = t.find("option:selected").val(),
- a = t.find("option:selected").attr("data-product-edition-variant-price");
- if (a = tcart__cleanPrice(a), void 0 !== o && void 0 !== r) {
- var i = {};
- "" != o && (o = tcart__escapeHtml(o)), "" != r && (r = (r = tcart__escapeHtml(r)).replace(/(?:\r\n|\r|\n)/g, "")), 1 < o.length && ":" == o.charAt(o.length - 1) && (o = o.substring(0, o.length - 1)), i.option = o, i.variant = r, i.price = a, f.push(i)
- }
- }), m.find(".js-product-option").each(function() {
- var t = $(this),
- o = t.find(".js-product-option-name").text(),
- r = t.find("option:selected").val(),
- a = t.find("option:selected").attr("data-product-variant-price");
- if (a = tcart__cleanPrice(a), void 0 !== o && void 0 !== r) {
- var i = {};
- "" != o && (o = tcart__escapeHtml(o)), "" != r && (r = (r = tcart__escapeHtml(r)).replace(/(?:\r\n|\r|\n)/g, "")), 1 < o.length && ":" == o.charAt(o.length - 1) && (o = o.substring(0, o.length - 1)), i.option = o, i.variant = r, i.price = a, f.push(i)
- }
- }), "" == d && void 0 === (d = m.find(".js-product-sku").text()) && (d = "")
- }
- if ("" != i || "" != a && 0 != a) {
- "" == i && (i = "NoName"), "" == a && (a = 0), "" != i && (i = tcart__escapeHtml(i)), "" != c && (c = tcart__escapeHtmlImg(c));
- var h = {};
- if (h.name = i, h.price = a, h.img = c, h.recid = s, void 0 !== f && 0 < f.length && (h.options = f), void 0 !== d && "" != d && (d = tcart__escapeHtml(d), h.sku = d), void 0 !== e && "" != e && (h.uid = e), void 0 !== _ && 0 < _ && (h.inv = parseInt(_)), tcart__addProduct(h), void 0 !== window.tcart_sendevent_onadd && "y" == window.tcart_sendevent_onadd && window.Tilda && "function" == typeof Tilda.sendEventToStatistics) {
- var b = "/tilda/cart/add/";
- 0 < s && (b += s), 0 < n && (b += "-" + n);
- var g = i,
- P = a,
- x = "";
- void 0 !== f && 0 < f.length && $.each(f, function(t, o) {
- x += o.option + ": " + o.variant + "; "
- });
- var C = {
- ecommerce: {
- add: {
- products: [{
- recid: s,
- lid: n,
- sku: d,
- name: i,
- price: a,
- variant: x,
- quantity: 1
- }]
- }
- }
- };
- Tilda.sendEventToStatistics(b, g, C, P)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement