var orichiTiktokElementButtonCheckout='#mu-checkout-button, .shopify-payment-button__button,form[action^="/checkout"] [name^="checkout"],form[action^="/checkout"] .checkout-button,.checkout_btn,.OTCheckout,[name^="checkout"],form[action^="/cart"] [name^="checkout"],form[action^="/cart"] .checkout-button,#cart .action_button.right, .btn-checkout, a[href="/checkout"],.cb-bundle_custom_checkout_button_selector span, .cart_button_secure[href^="/checkout"], button[data-checkout="checkout"]',orichiTiktokElementButtonAddToCart="button[data-add-to-cart-text], .single_add_to_cart_button, #addToCart, .product-form--atc-button,.gt_atom-gfJyZItCdWdircv_productButtonBuyItNow,.product-form__cart-submit,#teeAtcButton,#new-form-atc,.single_add_to_cart_button,#AddToCartForm button,.product__form button.add-to-cart, #AddToCart-product-template,.product-form__cart-submit,[name^='add'],button[data-pf-type='ProductATC'], .ProductForm__AddToCart,.product-form__add-button,.add-to-cart-btn,.ProductForm__AddToCart span,.tt-btn-addtocart,.btn-addtocart,.mfy-sticky-add-to-cart span,[name^='add'] span, .so-btn-add-to-cart-vanity-copy, .btn-addtocart span, .stickyaddtocart span, .vtl-ub-suggestion__add-to-cart";if(void 0!==__st.pageurl)var pageURL="https://"+__st.pageurl;else var pageURL=window.location.href;pageURL.indexOf("&")&&(pageURL=pageURL.split("&")[0]);var currency=Shopify.currency.active;!Shopify.Checkout||"thank_you"!=Shopify.Checkout.page&&"checkout_one_thank_you"!=Shopify.Checkout.page||"hello-8241.myshopify.com"!=Shopify.shop||(currency=Shopify.Checkout.currency);var isUseProductID=["gurudreads.myshopify.com","capefrigg.myshopify.com","bellefever-apac.myshopify.com","my-dream-store-final.myshopify.com","amano-ke.myshopify.com","hysouq.myshopify.com","amano-ghana.myshopify.com","amano-kenya.myshopify.com","goatfilm-tw.myshopify.com","tim-and-ted.myshopify.com","bonorganik-kids.myshopify.com"].indexOf(Shopify.shop)>=0,notIncludeShippingFee=["my-dream-store-final.myshopify.com","grem-store.myshopify.com"].indexOf(Shopify.shop)>=0,notUsingFbpFbc=["cezanny.myshopify.com","wwgenestore2.myshopify.com","shop1raven.myshopify.com"].indexOf(Shopify.shop)>=0,notUsingIC=["valenciajewels.myshopify.com"].indexOf(Shopify.shop)>=0,notUsingPurchase=["valenciajewels.myshopify.com","nossalojabuzz.myshopify.com"].indexOf(Shopify.shop)>=0;async function orichiInitTiktokPixel(){let pixels=await orichiGetAllTiktokPixels($);if(window.tiktokpixels=pixels,null!=pixels&&null!=pixels)for(var i=0;i0){if(pageURL.indexOf("/products/")>-1){var product_url;if(pageURL.indexOf("?")>-1)product_url=(product_url=pageURL.split("?"))[0]+".json";else var product_url=pageURL+".json";var product=await otGetInfoProductByLink(product_url,$);trackTiktokViewContent(pixels,product)}if(document.addEventListener("click",(function(event){event.target.matches(orichiTiktokElementButtonAddToCart)&&trackTiktokAddToCart(pixels)})),$("body").on("click",orichiTiktokElementButtonCheckout,(function(e){if("undefined"!=typeof itemInCart&&void 0!==itemInCart.items){var cart=itemInCart;if(cart.items.length>0){let contents=[],content_ids=[],content_name=[];$.each(cart.items,(function(index,value){content_ids.push(isUseProductID?value.product_id:value.variant_id),content_name.push(value.product_title),contents.push({content_id:isUseProductID?value.product_id.toString():value.variant_id.toString(),content_name:value.product_title,content_category:"0",content_type:"product_group",price:value.price/100,quantity:value.quantity}),index==cart.items.length-1&&trackTiktokInitiateCheckout(pixels,contents,cart)}))}}else $.ajax({type:"GET",url:"/cart.json",dataType:"json",async:!1}).done(cart=>{if(cart.items.length>0){let contents=[],content_ids=[],content_name=[];$.each(cart.items,(function(index,value){content_ids.push(isUseProductID?value.product_id:value.variant_id),content_name.push(value.product_title),contents.push({content_id:isUseProductID?value.product_id.toString():value.variant_id.toString(),content_name:value.product_title,content_category:"0",content_type:"product_group",price:value.price/100,quantity:value.quantity}),index==cart.items.length-1&&trackTiktokInitiateCheckout(pixels,contents,cart)}))}}).fail((function(jqXHR,textStatus){}))})),Shopify.Checkout&&("thank_you"==Shopify.Checkout.page||"checkout_one_thank_you"==Shopify.Checkout.page)){var productIds=[],productNames=[],contents=[],quantity=0;Shopify.checkout.line_items.forEach((function(item,index){if(quantity+=item.quantity,""!=item.variant_title)var prod_name=item.title+" - "+item.variant_title;else var prod_name=item.title;productNames.push(prod_name),productIds.push(isUseProductID?item.product_id:item.variant_id),contents.push({content_id:isUseProductID?item.product_id.toString():item.variant_id.toString(),content_name:item.product_title,content_category:"0",content_type:"product_group",price:item.price,quantity:item.quantity})})),trackTiktokPurchase($,contents,quantity,pixels)}}}function otGetInfoProductByLink(URL,$){return new Promise(resolve=>{$.ajax({url:URL,dataType:"jsonp",header:{"Access-Control-Allow-Origin":"*"},success:function(responseData){"string"==typeof responseData&&(responseData=JSON.parse(responseData)),responseData.product.title.indexOf("'")>-1&&(responseData.product.title=responseData.product.title.replace(/'/g,"")),resolve(responseData.product)}})})}function trackTiktokViewContent(pixels,product){console.log("product",product);let event_id="ottq"+(new Date).getTime();orttq(pixels,"ViewContent",{content_id:isUseProductID?product.id.toString():0==product.variants.length||null==product.variants?product.id.toString():product.variants[0].id.toString(),content_type:"product_group",price:product.variants[0].price,value:product.variants[0].price,content_name:product.title,currency:currency},event_id)}function trackTiktokAddToCart(pixels){$.ajax({type:"GET",url:"/cart.json",dataType:"json"}).done(cart=>{if(cart.items.length>0){var lastItem=cart.items[0],quantity=null!=$('input[name="quantity"]').val()?$('input[name="quantity"]').val():1,value=parseInt(cart.total_price)/100;"loccitane-thailand.myshopify.com"==Shopify.shop&&(value=parseInt(lastItem.price)/100);let event_id="ottq"+(new Date).getTime()+getRandomInt(1,1e5);orttq(pixels,"AddToCart",{content_id:isUseProductID?lastItem.product_id:lastItem.variant_id,content_type:"product_group",content_category:"0",value:quantity*value,quantity:quantity,content_name:lastItem.product_title,currency:currency},event_id)}else if(void 0!==__st.rid&&void 0!==meta.product.variants[0].id){var quantity=null!=$('input[name="quantity"]').val()?$('input[name="quantity"]').val():1;let event_id="ottq"+(new Date).getTime()+getRandomInt(1,1e5);orttq(pixels,"AddToCart",{content_id:isUseProductID?meta.product.id:meta.product.variants[0].id,content_type:"product_group",content_category:"0",quantity:quantity,value:quantity*parseInt(meta.product.variants[0].price)/100,content_name:meta.product.variants[0].name,currency:currency},event_id)}})}function trackTiktokInitiateCheckout(pixels,contents,cart){if(!notUsingIC){let event_id="ottq"+(new Date).getTime()+getRandomInt(1,1e5);orttq(pixels,"InitiateCheckout",{contents:contents,currency:currency,value:(parseFloat(cart.total_price)/100).toString()},event_id)}}function trackTiktokPurchase($,contents,quantity,pixels){notUsingPurchase||orttq(pixels,"Purchase",{currency:currency,value:Shopify.checkout.subtotal_price,contents:contents,content_type:"product_group",quantity:quantity},Shopify.checkout.order_id)}function orichiGetAllTiktokPixels($){"use strict";return new Promise(resolve=>{$.ajax({url:"https://pixel.orichi.info/Customer/GetTiktokPixel?domain="+Shopify.shop,type:"GET",success:function(res){null!=res&&(res=res.filter(p=>p.Status)),resolve(res)}})})}function ottpGenerateID(){let date=new Date;return btoa("or-tt-pixel"+(new Date).toLocaleDateString())}!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i0&&("object"==typeof arguments[0]&&(pixelIds=arguments[0]),"string"==typeof arguments[1]&&(trackType=arguments[1]),"object"==typeof arguments[2]&&(contentObj=arguments[2]),void 0!==arguments[3]&&(eventID=arguments[3]),""!=eventID&&void 0!==eventID||(eventID=(new Date).getTime()+getRandomInt(1,1e5)),"string"==typeof trackType&&trackType.replace(/\s+/gi,"")))for(var i=0;i