PageSourceSearch

https://junglueck.de/cdn/shop/t/676/assets/add-to-cart-component.js?v=113224783720971278601763543823

js junglueck.de collected 2026-10-02 07:19:23 UTC 3,577 bytes, 10 lines download raw bytes

1class AddToCart extends HTMLElement{constructor(){super()}addToCartVariant(variantId){const that=this;that.classList.add("loading"),fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:variantId,quantity:1}],sections:["cart-drawer","cart-main"]})}).then(response=>response.json()).then(response=>{if(response.status){const error_string=`
2CART GET FAILED 
3Status: ${response.status} 
4Message: ${response.message} 
5Description: ${response.description}`;throw new Error(error_string,{cause:"Cart Error"})}else that.classList.remove("loading"),window.dispatchEvent(new CustomEvent("cart:add",{detail:{...response,added_count:1}}))}).catch(error=>{that.classList.remove("loading"),console.error(error)})}getUniqueId(){let firstPart=Math.random()*46656|0,secondPart=Math.random()*46656|0;return firstPart=("000"+firstPart.toString(36)).slice(-3),secondPart=("000"+secondPart.toString(36)).slice(-3),firstPart+secondPart}addToCart(form){const that=this,uniqeID=that.getUniqueId();form.querySelectorAll("input[data-value-unique]").forEach(input=>{let setMini=!1;input.value?.includes("_mini")&&(setMini=!0),input.value=uniqeID,setMini&&(input.value=`${input.value}_mini`)});const formData=new FormData(form),components=[];if(formData.get("add_type")==="bundle"){const formDataEntries=Array.from(formData.entries()),component_variant_ids=formDataEntries.filter(entry=>entry[0].includes("items[")&&entry[0].includes("]id")).map(entry=>entry[1]),component_product_ids=formDataEntries.filter(entry=>entry[0].includes("items[")&&entry[0].includes("]product_id")).map(entry=>entry[1]),component_amounts=formDataEntries.filter(entry=>entry[0].includes("items[")&&entry[0].includes("]amount")).map(entry=>entry[1]),component_quantities=formDataEntries.filter(entry=>entry[0].includes("items[")&&entry[0].includes("]quantity")).map(entry=>entry[1]);component_variant_ids.forEach((variant_id,index)=>{const component={variant_id,product_id:component_product_ids[index],amount:component_amounts[index],quantity:component_quantities[index]};components.push(component)})}formData.append("sections",["cart-drawer","cart-main"]),that.classList.add("loading"),fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",credentials:"same-origin",body:formData}).then(response=>response.json()).then(response=>{if(response.status){const error_string=`
6CART GET FAILED 
7Status: ${response.status} 
8Message: ${response.message} 
9Description: ${response.description}`;throw new Error(error_string,{cause:"Cart Error"})}else that.classList.remove("loading"),window.dispatchEvent(new CustomEvent("cart:add",{detail:{...response,add_type:formData.get("add_type")==="bundle"?"bundle":"single",components,added_count:Number(formData.get("quantity"))||1}}))}).catch(error=>{that.classList.remove("loading"),console.error(error)})}connectedCallback(){const variantId=this.getAttribute("variant-id")||null;if(variantId){this.addEventListener("click",event=>{event.preventDefault(),event.stopPropagation(),this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"||this.addToCartVariant(Number(variantId))});return}const form=this.closest("form");form&&this.addEventListener("click",event=>{event.preventDefault(),event.stopPropagation(),this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"||this.addToCart(form)})}}customElements.define("add-to-cart",AddToCart);
10//# sourceMappingURL=/cdn/shop/t/676/assets/add-to-cart-component.js.map?v=113224783720971278601763543823

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.