1 line
1.3 KiB
JavaScript
1 line
1.3 KiB
JavaScript
(()=>{"use strict";var e,t={};t.d=(e,r)=>{for(var a in r)t.o(r,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(e=t.g.jQuery)&&(e("body").on("edd_cart_item_added",(e,r)=>{const{name:a,value:o}=function(e){const t=(new DOMParser).parseFromString(e,"text/html"),r=t.querySelector(".edd-cart-item-title")?.textContent.trim()||"";let a=(t.querySelector(".edd-cart-item-price")?.textContent.trim()||"").replace(/[^\d.,]/g,"").trim();const o=a.lastIndexOf(","),i=a.lastIndexOf(".");return o>-1&&i>-1?a=o>i?a.replace(/\./g,"").replace(",","."):a.replace(/,/g,""):o>-1?a=3===a.length-o?a.replace(",","."):a.replace(/,/g,""):i>-1&&3!==a.length-i&&(a=a.replace(/\./g,"")),{name:r,value:parseFloat(a)||0}}(r.cart_item),i=t.g._googlesitekit.easyDigitalDownloadsCurrency;t.g._googlesitekit?.gtagEvent?.("add_to_cart",{currency:i,value:o,items:[{item_name:a,price:o}]})}),t.g._googlesitekit?.gtagUserData&&t.g._googlesitekit?.edddata?.purchase?.user_data&&t.g._googlesitekit?.gtagEvent?.("purchase",{user_data:t.g._googlesitekit.edddata.purchase.user_data}))})(); |