PageSourceSearch

https://twobrothersindiashop.com/cdn/shop/t/809/assets/cart-free-s…&enable_js_minification=1

js twobrothersindiashop.com collected 2026-10-01 10:41:28 UTC 3,996 bytes, 2 lines download raw bytes

1class CartFreeSample extends HTMLElement{constructor(){super()}connectedCallback(){this.cartAddFreeSample()}cartAddFreeSample(){fetch("/cart",{method:"POST",headers:{"Content-Type":"application/json"}}).then(response=>response.text()).then(data=>{cartData(data)});function cartData(data){let cartAjax=document.querySelector("cart-drawer#mini-cart"),cartSubtotal=data.total_price/100,cartSampleId=parseInt(cartAjax.getAttribute("data-free-sample-id")),sampleThreshold=parseInt(cartAjax.getAttribute("data-free-sample-price"));document.querySelectorAll('input[id^="free-product__"]').forEach(function(giftCheckbox){giftCheckbox.addEventListener("change",function(){let isChecked=giftCheckbox.checked;const sampleId=giftCheckbox.getAttribute("data-sample-id");cartSubtotal>=sampleThreshold&&(isChecked&&!cartSampleId?(addToCart(sampleId),disableOtherSamples(sampleId)):!isChecked&&parseInt(sampleId)?removeFreeSample(sampleId):isChecked&&cartSampleId&&warningMessage())})}),cartSampleId!=NaN&&cartSubtotal<sampleThreshold&&removeFreeSample(cartSampleId)}function disableOtherSamples(selectedSampleId){giftCheckboxes.forEach(function(giftCheckbox){const sampleId=giftCheckbox.getAttribute("data-sample-id"),productWrapper=giftCheckbox.closest(".freegift-product--wrapper");sampleId!==selectedSampleId?giftCheckbox.disabled=!0:giftCheckbox.disabled=!1})}function addToCart(variantId){let formData={items:[{id:variantId,quantity:1,properties:{_freeSample:"true"}}]};formData.sections="mini-cart",fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(formData)}).then(response=>{if(response.ok)return response.json();throw new Error("Network response was not ok.")}).then(data=>{if(document.querySelector(".header__cart-count")){let CartCount=parseInt(document.querySelector(".header__cart-count").innerHTML);CartCount+=1,document.querySelector(".header__cart-count").innerHTML=CartCount}let miniCartSection=data.sections["mini-cart"],tempDiv=document.createElement("div");tempDiv.innerHTML=miniCartSection;let miniCart=tempDiv.querySelector("#shopify-section-mini-cart"),oldCartDrawer=document.querySelector("#shopify-section-mini-cart");miniCart.querySelector("#mini-cart").setAttribute("open","true"),oldCartDrawer.innerHTML=miniCart.innerHTML,getFreeBeeToaster()}).catch(error=>console.error("Error:",error))}function removeFreeSample(sampleId){const data={updates:{[sampleId]:0},sections:"mini-cart"};fetch(window.Shopify.routes.root+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(data)}).then(response=>response.json()).then(data2=>{let miniCartSection=data2.sections["mini-cart"],tempDiv=document.createElement("div");tempDiv.innerHTML=miniCartSection;let miniCart=tempDiv.querySelector("#shopify-section-mini-cart"),oldCartDrawer=document.querySelector("#shopify-section-mini-cart");if(miniCart.querySelector("#mini-cart").setAttribute("open","true"),oldCartDrawer.innerHTML=miniCart.innerHTML,document.querySelector(".header__cart-count")){let cartCount=parseInt(document.querySelector(".header__cart-count").innerHTML);cartCount-=1,document.querySelector(".header__cart-count").innerHTML=cartCount}REFRESH_CART()}).catch(error=>console.error("Error:",error))}function getFreeBeeToaster(){const giftToaster=document.querySelector(".free-gift-toaster");giftToaster.innerHTML="Free Sample Added",giftToaster.setAttribute("open","true"),setTimeout(()=>{hideToaster()},3e3)}function warningMessage(){const giftToaster=document.querySelector(".free-gift-toaster");giftToaster.innerHTML="You can't Add more than one product",giftToaster.setAttribute("open","true"),setTimeout(()=>{hideToaster()},3e3)}function hideToaster(){document.querySelector(".free-gift-toaster").removeAttribute("open")}}}customElements.define("cart-free-sample",CartFreeSample);
2//# sourceMappingURL=/cdn/shop/t/809/assets/cart-free-sample.js.map?enable_js_minification=1&v=144137373606194748371790683327

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.