TK-01 | Terra Kaffe
Posted by:
Category:
Comments:
Post Date:
TK-01 | Terra Kaffe
[]
TK-01 | Terra Kaffe – Terra Kaffe 1 && !$.isFunction(b)) { c = $.extend({}, h.defaults, c); if (typeof c.expires === 'number') { var d = c.expires, t = c.expires = new Date(); t.setMilliseconds(t.getMilliseconds() + d * 864e+5) } return (document.cookie = [encode(a), '=', stringifyCookieValue(b), c.expires ? '; expires=' + c.expires.toUTCString() : '', c.path ? '; path=' + c.path : '', c.domain ? '; domain=' + c.domain : '', c.secure ? '; secure' : ''].join('')) } var e = a ? undefined : {}, cookies = document.cookie ? document.cookie.split('; ') : [], i = 0, l = cookies.length; for (; i 0) { if (Shopify.Checkout.step === 'contact_information') { dataLayer.push(transactionData, { 'event': 'Customer Information', 'pageType': 'Customer Information' }); console.log("Customer Information - Transaction Data" + " :" + JSON.stringify(transactionData, null, " ")); } else if (Shopify.Checkout.step === 'shipping_method') { dataLayer.push(transactionData, { 'event': 'Shipping Information', 'pageType': 'Shipping Information' }); console.log("Shipping - Transaction Data" + " :" + JSON.stringify(transactionData, null, " ")); } else if (Shopify.Checkout.step === "payment_method") { dataLayer.push(transactionData, { 'event': 'Add Payment Info', 'pageType': 'Add Payment Info' }); console.log("Payment - Transaction Data" + " :" + JSON.stringify(transactionData, null, " ")); } } if (__DL__.debug == true) { /** DATALAYER: Transaction */ if (Shopify.Checkout.page == "thank_you") { dataLayer.push(transactionData, { 'pageType': 'Transaction', 'event': 'Transaction' }); console.log("Transaction Data" + " :" + JSON.stringify(transactionData, null, " ")); } } else { /** DATALAYER: Transaction */ if (Shopify.Checkout.page == "thank_you") { dataLayer.push(transactionData, { 'pageType': 'Transaction', 'event': 'Transaction' }); } } } } /** DATALAYER: All Pages * Fire all pages trigger after all additional dataLayers have loaded. */ dataLayer.push({ 'event': 'DataLayer Loaded' }); console.log('DATALAYER: DataLayer Loaded.'); /********************** * DATALAYER EVENT BINDINGS ***********************/ /** DATALAYER: * Add to Cart / Dynamic Cart View * Fire all pages trigger after all additional dataLayers have loaded. */ $(document).ready(function () { /** DATALAYER: Search Results */ var searchPage = new RegExp(__DL__.searchPage, "g"); if (document.location.pathname.match(searchPage)) { var search = { 'searchTerm': __DL__.searchTermQuery, 'pageType': "Search", 'event': "Search" }; dataLayer.push(search); if (__DL__.debug) { console.log("Search" + " :" + JSON.stringify(search, null, " ")); } } /** DATALAYER: Cart */ // stage cart data function mapJSONcartData() { jQuery.getJSON('/cart.js', function (response) { // get Json response __DL__.cart = response; var cart = { 'products': __DL__.cart.items.map(function (line_item) { return { 'id': line_item.id, 'sku': line_item.sku, 'variant': line_item.variant_id, 'name': line_item.title, 'price': (line_item.price / 100), 'quantity': line_item.quantity } }), 'pageType': 'Cart', 'event': 'Cart' }; if (cart.products.length > 0) { dataLayer.push(cart); if (__DL__.debug) { console.log("Cart" + " :" + JSON.stringify(cart, null, " ")); } } }); } viewcartfire = 0; // view cart $(__DL__.viewCart).on('click', function (event) { if (viewcartfire !== 1) { viewcartfire = 1; // if dynamic cart is TRUE if (__DL__.dynamicCart) { cartCheck = setInterval(function () { // begin check interval if ($(__DL__.cartVisableSelector).length > 0) { // check visible selectors clearInterval(cartCheck); mapJSONcartData(); $(__DL__.removeCartTrigger).on('click', function (event) { // remove from cart var link = $(this).attr("href"); jQuery.getJSON(link, function (response) { // get Json response __DL__.removeCart = response; var removeFromCart = { 'products': __DL__.removeCart.items.map(function (line_item) { return { 'id': line_item.id, 'sku': line_item.sku, 'variant': line_item.variant_id, 'name': line_item.title, 'price': (line_item.price / 100), 'quantity': line_item.quantity } }), 'pageType': 'Remove from Cart', 'event': 'Remove from Cart' }; dataLayer.push(removeFromCart); if (__DL__.debug) { console.log("Cart" + " :" + JSON.stringify(removeFromCart, null, " ")); } }); }); } }, 500); } } }); // add to cart jQuery.getJSON('/cart.js', function (response) { // get Json response __DL__.cart = response; var cart = { 'products': __DL__.cart.items.map(function (line_item) { return { 'id': line_item.id, 'sku': line_item.sku, 'variant': line_item.variant_id, 'name': line_item.title, 'price': (line_item.price / 100), 'quantity': line_item.quantity } }) } __DL__.cart = cart; collection_cartIDs = []; collection_matchIDs = []; collection_addtocart = []; for (var i = __DL__.cart.products.length - 1; i >= 0; i--) { var x = parseFloat(__DL__.cart.products[i].variant); collection_cartIDs.push(x); } }); function __DL__addtocart() { dataLayer.push(product, { 'pageType': 'Add to Cart', 'event': 'Add to Cart' }); if (__DL__.debug) { console.log("Add to Cart" + " :" + JSON.stringify(product, null, " ")); } // if dynamic cart is TRUE if (__DL__.dynamicCart) { console.log("dynamic"); var cartCheck = setInterval(function () { // begin check interval if ($(__DL__.cartVisableSelector).length > 0) { // check visible selectors clearInterval(cartCheck); mapJSONcartData(); $(__DL__.removeCartTrigger).on('click', function (event) { // remove from cart var link = $(this).attr("href"); jQuery.getJSON(link, function (response) { // get Json response __DL__.removeCart = response; var removeFromCart = { 'products': __DL__.removeCart.items.map(function (line_item) { return { 'id': line_item.id, 'sku': line_item.sku, 'variant': line_item.variant_id, 'name': line_item.title, 'price': (line_item.price / 100), 'quantity': line_item.quantity } }), 'pageType': 'Remove from Cart', 'event': 'Remove from Cart' }; dataLayer.push(removeFromCart); if (__DL__.debug) { console.log("Cart" + " :" + JSON.stringify(removeFromCart, null, " ")); } }); }); } }, 500); } } $(document).on('click', __DL__.cartTriggers, function () { __DL__addtocart(); }); /** * DATALAYER: Newsletter Subscription */ __DL__newsletter_fire = 0; $(document).on('click', __DL__.newsletterSelectors, function () { if (__DL__newsletter_fire !== 1) { __DL__newsletter_fire = 1; var newsletterCheck = setInterval(function () { // begin check interval if ($(__DL__.newsletterSuccess).length > 0) { // check visible selectors clearInterval(newsletterCheck); dataLayer.push({ 'event': 'Newsletter Subscription' }); } }, 500); } }); /** DATALAYER: Wishlist */ setTimeout(function () { $(__DL__.wishlistSelector).on('click', function () { dataLayer.push(product, { 'event': 'Add to Wishlist' }); if (__DL__.debug) { console.log("Wishlist" + " :" + JSON.stringify(product, null, " ")); } }); if (document.location.pathname == __DL__.wishlistPage) { var __DL__productLinks = $('[href*="product"]'); var __DL__prods = []; var __DL__links = []; var __DL__count = 1; $(__DL__productLinks).each(function () { var href = $(this).attr("href"); if (!__DL__links.includes(href)) { __DL__links.push(href); $(this).attr("dataLayer-wishlist-item", __DL__count++); jQuery.getJSON(href, function (response) { // get Json response __DL__.wishlist = response; var wishlistproducts = { 'id': __DL__.wishlist.product.id, 'name': __DL__.wishlist.product.title, }; __DL__prods.push(wishlistproducts); }); } }); dataLayer.push({ 'products': __DL__prods, 'pageType': 'Wishlist', 'event': 'Wishlist' }); } var __DL__count = 1; var wishlistDel = $(__DL__.removeWishlist); wishlistDel.each(function () { $(this).attr("dataLayer-wishlist-item-del", __DL__count++); }); $(__DL__.removeWishlist).on('click', function () { console.log('click') var index = $(this).attr("dataLayer-wishlist-item-del"); var link = $("[dataLayer-wishlist-item=" + index + "]").attr("href"); console.log(index) console.log(link) jQuery.getJSON(link, function (response) { // get Json response __DL__.wishlist = response; var wishlistproducts = { 'id': __DL__.wishlist.product.id, 'name': __DL__.wishlist.product.title, }; dataLayer.push({ 'products': wishlistproducts, 'pageType': 'Wishlist', 'event': 'Wishlist Delete Product' }); }); }) }, 3000); /** DATALAYER: CTAs */ $(__DL__.ctaSelectors).on('click', function () { var ctaCheck = setInterval(function () { // begin check interval if ($(__DL__.ctaSuccess).length > 0) { // check visible selectors clearInterval(ctaCheck); dataLayer.push({ 'event': 'CTA' }); } }, 500); }); /** DATALAYER: Promo Subscriptions */ $(__DL__.promoSubscriptionsSelectors).on('click', function () { var ctaCheck = setInterval(function () { // begin check interval if ($(__DL__.promoSuccess).length > 0) { // check visible selectors clearInterval(ctaCheck); dataLayer.push({ 'event': 'Promo Subscription' }); } }, 500); }); }); // document ready } }, 500); ]]> Skip to content `) } async function getCartMulberryWarranty({item, product}) { const body = { id: item.id, title: item.product.title, price: item.product.price, detail: product, } const offers = await mulberry.core.getWarrantyOffer(body); return { offers } } async function setupOffers({item, product, container}) { if (item.id === 42969799590145){ // ignoring waterline return; } const url = product.url; const { product: mulberryProduct } = await mulberryShop.getProductData(url) const { offers } = await getCartMulberryWarranty({item: { ...item, product}, product: mulberryProduct}); // add offers to the container const offerContainer = container.querySelector(`#mulberry-inline-container-${item.id}`); if (!offers.length || !offerContainer) return false; const offersSnippet = offers.map((offer, index) => getCartOfferSnippet(offer, index + 1, item, container)) offerContainer.innerHTML = offersSnippet.join("") + `
No thanks
`; // add to cart functionality for radio buttons offers.forEach((offer) => { const addOfferButton = offerContainer.querySelector(`div[data-offer-id="${offer.id}"] input`); if (addOfferButton) { addOfferButton.addEventListener('click', async () => { await onCartAddWarranty(mulberryProduct, offer) }); } }) } async function setupUpsellOffers({item, product, container, index}) { const url = product.url; const { product: mulberryProduct } = await mulberryShop.getProductData(url) const { offers } = await getCartMulberryWarranty({item: { ...item, product}, product: mulberryProduct}); offers.forEach((offer, offerIdx) => { if (index === offerIdx) { const productTitle = container.querySelector(`.product-title`); productTitle.textContent = `${offerIdx + 1} Year Extended Warranty`; const productPrice = container.querySelector(`.product-price`); productPrice.textContent = `$${offer.cost}`; const addOfferButton = container.querySelector(`button[name="add"]`); if (addOfferButton) { addOfferButton.addEventListener('click', async (event) => { await upsellAddWarranty(mulberryProduct, offer) }); } } }) } async function onCartAddWarranty(product, offer) { const result = await mulberryShop.getWarrantyVariant(offer); const response = await mulberryShop.addWarrantyToCart(result.shopify_variant_id, { ...product, variantId: offer.product_meta.id, }, offer); refreshCart(); } async function upsellAddWarranty(product, offer) { const result = await mulberryShop.getWarrantyVariant(offer); const response = await mulberryShop.addWarrantyToCart(result.shopify_variant_id, { ...product, variantId: offer.product_meta.id, }, offer); refreshCart(false); } function initializeMulberry() { function updateItemOffers() { // iterate through all the mulberry containers to parse the right data document.querySelectorAll(".mulberry-container").forEach((selector) => { const itemRaw = selector.querySelector("[data-item-type='item']").textContent; const productRaw = selector.querySelector("[data-item-type='product']").textContent; const item = JSON.parse(itemRaw); const product = JSON.parse(productRaw); setupOffers({item, product, container: selector}); }) const upsellData = document.querySelector("#upsell-mulberry-data"); if (upsellData) { const productCards = document.querySelectorAll(".warranty-step .upsell-flow-product-card"); const itemRaw = upsellData.querySelector("[data-item-type='item']").textContent; const productRaw = upsellData.querySelector("[data-item-type='product']").textContent; const item = JSON.parse(itemRaw); const product = JSON.parse(productRaw); productCards.forEach((selector, index) => { setupUpsellOffers({item, product, container: selector, index}); }); } } document.addEventListener('mulberry-shopify:loaded', async () => { try { updateItemOffers() } catch (e) { console.error(e); } }) document.addEventListener('tk:cart-updated', async () => { try { refreshCart(false); updateItemOffers() } catch (e) { console.error(e); } }) } initializeMulberry();Loading...
{ scrollToHash(); }, 1000); }) ]]> { const isVideoElement = element.nodeName === 'VIDEO' if (isVideoElement) { element.pause(); setTimeout(() => { element.play(); element.style.zIndex = 5; }, 2000) } }, }); }); }); ]]> SourceShare this post
Related
Posts
Coffee
Palm Coast Coffee – Beach Brew at Hammock Beach
Your morning - elevated. A contemporary coffee outlet where craft coffee is the star of the show. Beach Brew will feature artisan...
Coffee
5 Great Places to Grab Coffee in Flagler Beach
Whether you require a bold cup to start your day or an icy afternoon refresher, Flagler Beach’s independent coffee shops...
Coffee
11 Best Coffee Shops In Downtown Asheville, NC
Explore the best coffee shops in Downtown Asheville serving delicious treats, food, and specialty beverages – from locals. We love...
Coffee
15 North Carolina Coffee Shops and Cafés You’ll Like a Latte
11 Smelly Cat CoffeehouseCharlotteSee on mapNestled in Charlotte’s arts and entertainment district known as NoDa, Smelly Cat Coffeehouse features a...