Created
October 15, 2024 15:42
-
-
Save jahilldev/fed6d4419ed1ef720100b5d261e71597 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="/apps/invites/checkout-snippet.css"> | |
<script src="/apps/invites/checkout-snippet.js" crossorigin="anonymous"></script> | |
<!-- sovendus code begin --> | |
<div style="margin-top: 30px" id="sovendus-container-1"></div> | |
<script type="text/javascript"> | |
const sovendusIdsByCountry = { | |
GB: { | |
trafficSourceNumber: "7473", | |
trafficMediumNumber: "1", | |
}, | |
}; | |
const staticVoucher = "SOVSUBS"; | |
const countryCode = "{{checkout.billing_address.country_code}}"; | |
const language = document.documentElement.lang?.split("-")?.[0]; | |
const sovendusIds = | |
sovendusIdsByCountry[countryCode] || | |
sovendusIdsByCountry[`${countryCode}-${language}`]; | |
if (sovendusIds) { | |
const taxPercent = Number( | |
"{% for tax_line in checkout.tax_lines %}{{ tax_line.rate }}{% endfor %}" | |
); | |
const totalPrice = Number("{{checkout.total_price}}"); | |
const shippingPrice = Number("{{checkout.shipping_price}}"); | |
taxPercent = isNaN(taxPercent) ? 0 : taxPercent; | |
totalPrice = isNaN(totalPrice) ? 0 : totalPrice; | |
shippingPrice = isNaN(shippingPrice) ? 0 : shippingPrice; | |
const grossOrderValue = (totalPrice - shippingPrice) * 0.01; | |
const netOrderValue = grossOrderValue - grossOrderValue * taxPercent; | |
const firstCouponCode = "{{ checkout.discount_applications.first.title }}"; | |
const lastCouponCode = "{{ checkout.discount_applications.last.title }}"; | |
const isSovendusCookiePresent = | |
!!document.cookie.split("; ").find(function (entry) { | |
return entry.startsWith("sovendus="); | |
}) || null; | |
let couponCode = lastCouponCode.toLowerCase().includes("sov") | |
? lastCouponCode | |
: firstCouponCode; | |
couponCode = isSovendusCookiePresent ? staticVoucher : couponCode; | |
window.sovIframes = window.sovIframes || []; | |
window.sovIframes.push({ | |
trafficSourceNumber: sovendusIds.trafficSourceNumber, | |
trafficMediumNumber: sovendusIds.trafficMediumNumber, | |
sessionId: "{{checkout.order_id}}" + netOrderValue, | |
timestamp: Math.floor(Date.now() / 1000), | |
orderId: "{{checkout.order_id}}", | |
orderValue: netOrderValue, | |
orderCurrency: "{{checkout.currency}}", | |
usedCouponCode: couponCode, | |
iframeContainerId: "sovendus-container-1", | |
integrationType: "shopify-1.4.0", | |
}); | |
window.sovConsumer = { | |
consumerSalutation: "", | |
consumerFirstName: "{{checkout.billing_address.first_name}}", | |
consumerLastName: "{{checkout.billing_address.last_name}}", | |
consumerEmail: "{{checkout.email}}", | |
consumerCountry: "{{checkout.billing_address.country_code}}", | |
consumerZipcode: "{{checkout.billing_address.zip}}", | |
}; | |
const script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.async = true; | |
script.src = | |
window.location.protocol + | |
"//api.sovendus.com/sovabo/common/js/flexibleIframe.js"; | |
document.body.appendChild(script); | |
} | |
</script> | |
<!-- sovendus code end --> | |
<script type="text/javascript"> | |
(function(c,l,a,r,i,t,y){ | |
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; | |
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; | |
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); | |
})(window, document, "clarity", "script", "jr2ysu7ula"); | |
</script> | |
<!-- Google Tag Manager --> | |
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | |
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | |
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | |
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | |
})(window,document,'script','dataLayer','GTM-MZDQS5TH');</script> | |
<!-- End Google Tag Manager --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment