PageSourceSearch

https://memorystitch.com/cdn/shop/t/66/assets/add-multiple-to-cart.js?v=55303818013858906201739156112

js memorystitch.com collected 2026-10-04 09:15:37 UTC 12,536 bytes, 2 lines download raw bytes

1function getCartItems(){return fetch("/cart.json").then(response=>response.json()).then(data=>data.items.map(item=>({projectName:item.properties?.["Project Name"]})).filter(item=>item.projectName)).catch(error=>(console.error("Error fetching cart data:",error),[]))}async function hasDuplicateProjectNames(arr){let mergedArray,projectNames,uniqueNames;return getCartItems().then(cartItems=>(mergedArray=[...cartItems.map(item=>({projectName:item.projectName.replace(/\|$/,"").trim()})),...arr],mergedArray)).then(mergedArray2=>(projectNames=mergedArray2.filter(item=>item&&item.projectName).map(item=>item.projectName),projectNames)).then(projectNames2=>(uniqueNames=new Set(projectNames2),uniqueNames.size<projectNames2.length)).catch(error=>(console.error("Error:",error),!1))}async function addProductToCart(key,requestData,cartObjectArray2){await $.ajax({url:"https://memorystitch.com/cart/add.js",type:"POST",data:JSON.stringify(requestData),contentType:"application/json",dataType:"json",async:!1,success:function(response){window.location.href="/cart?reload_key="+key},error:function(error){console.error(error),window.location.href="/cart?reload_key="+key}})}async function fetchCartUpdate(key){await fetch("/cart/update.js",{method:"POST",body:JSON.stringify({updates:key}),headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"}).then(this.checkStatus).then(response=>response.json()).then(()=>{setTimeout(()=>{window.location.href="/cart?reload_key="+key},300)}).catch(error=>{console.error("Error updating cart:",error)})}async function addMultipleToCart(){multipleProjectToggle&&document.querySelector("#AddToCart-All").addEventListener("click",async e=>{if(e.preventDefault(),document.querySelectorAll(".validation-message").forEach(elem=>elem.remove()),document.querySelectorAll("[name=embroidered_message]")[document.querySelectorAll("[name=embroidered_message]").length-1].checked){let validInput="";const lineInputs=document.querySelectorAll(".line-inputs input");for(let i=0;i<lineInputs.length;i++)if(lineInputs[i].value){validInput=lineInputs[i].value;break}if(!validInput){const validationMessage=document.createElement("div");validationMessage.classList.add("validation-message"),validationMessage.textContent="Embroidery message lines cannot be blank",document.querySelector("#AddToCart-All").before(validationMessage),e.target.closest("#AddToCart-All").classList.remove("clicked");return}}if(e.target.closest("#AddToCart-All").classList.contains("clicked"))return;e.target.closest("#AddToCart-All").classList.add("clicked");const cartLength=cartObjectArray.length,projectNames=document.querySelectorAll('input[name="project_name"]'),lastProjectName=projectNames[projectNames.length-1],cutTshirts=document.querySelectorAll('input[name="cut_tshirts"]'),lastCutTshirt=cutTshirts[cutTshirts.length-1],embroideredMessages=document.querySelectorAll('input[name="embroidered_message"]'),lastEmbroideredMessage=embroideredMessages[embroideredMessages.length-1],rushProductions=document.querySelectorAll('input[name="rush_production"]'),lastRushProduction=rushProductions[rushProductions.length-1],priceItems=document.querySelectorAll(".price-item.price-item--regular"),lastPriceItem=priceItems[priceItems.length-1],componentIds=document.querySelectorAll("div[data-component-id]"),lastComponentId=componentIds[componentIds.length-1];let alreadyInObj=!1;if(cartObjectArray.forEach(obj=>{obj?.componentNumber&&obj?.componentNumber?.toString()===lastComponentId?.getAttribute("data-component-id")?.toString()&&(alreadyInObj=!0)}),alreadyInObj){if(await hasDuplicateProjectNames(cartObjectArray)){const validationMessage=document.createElement("div");validationMessage.classList.add("validation-message"),validationMessage.textContent="Project names must be unique.",cartObjectArray=[],document.querySelector("#AddToCart-All").before(validationMessage),e.target.closest("#AddToCart-All").classList.remove("clicked");return}e.target.closest("#AddToCart-All").querySelector("#AddToCartText-All").textContent="ADDING TO CART...",cartObjectArray.forEach((obj,index)=>{let cutVal="",embVal="",rushVal="",boldVariantNames=[],boldVariantIds=[],boldProductIds=[],boldProductPrices=[],cutShirtPrice=document.querySelectorAll('input[name="cut_tshirts"]')[0]?.value?.replace("$","")?.replace(".","")||"0",embroideredPrice=document.querySelectorAll('input[name="embroidered_message"]')[0]?.value?.replace("$","")?.replace(".","")||"0",rushPrice=document.querySelectorAll('input[name="rush_production"]')[0]?.value?.replace("$","")?.replace(".","")||"0";if(obj.cutShirt){let cutShirtVariantValue="37578658021552",cutShirtProductValue="6093630865584";cutShirtPrice.toString()==="999"&&(cutShirtVariantValue="37125886181552",cutShirtProductValue="5965525975216"),cutVal="\u2713",boldVariantNames.push("Let us cut your t-shirts"),boldVariantIds.push(cutShirtVariantValue),boldProductIds.push(cutShirtProductValue),boldProductPrices.push(cutShirtPrice)}obj.embroidered&&(embVal="\u2713",boldVariantNames.push("Add an embroidered message"),boldVariantIds.push("15908563812418"),boldProductIds.push("1927414251586"),boldProductPrices.push(embroideredPrice)),obj.rushProduction&&(rushVal="\u2713",boldVariantNames.push("Rush Production "),boldVariantIds.push("15378342838338"),boldProductIds.push("1927414251586"),boldProductPrices.push(rushPrice));let requestData;const randomNumber=Math.floor(Math.random()*1e9)+1,key=`${obj.variantId}_${randomNumber}`;if(obj.embroidered){const data={cb_923232_534844:{option_changed:{option_key:"cb_923232_534844",value:"checked",is_priced_option:!0,target_namespace:obj.variantId}}};localStorage.setItem(key,JSON.stringify(data)),requestData={form_type:"product",utf8:"\u2713",id:obj.variantId,"option-1":obj.color,"option-2":obj.color,properties:{"Project Name":obj.projectName+(cutVal!==""||embVal!==""?" |":""),"Let us cut your t-shirts":cutVal,"Add an embroidered message":embVal,Color:obj.fontColor,Font:obj.fontFace,"Line 1":obj.lineOne,"Line 2":obj.lineTwo,"Line 3":obj.lineThree,"Rush Production ":rushVal,_boldVariantNames:boldVariantNames.join(","),_boldVariantIds:boldVariantIds.join(","),_boldProductIds:boldProductIds.join(","),_boldVariantPrices:boldProductPrices.join(","),_boldBuilderId:`memorystitch_9a0bf1159f79c6ab0660ec422f350445_${randomNumber}`,_boldOptionLocalStorageId:key},quantity:"1",add:""}}else requestData={form_type:"product",utf8:"\u2713",id:obj.variantId,"option-1":obj.color,"option-2":obj.color,properties:{"Project Name":obj.projectName+(cutVal!==""||embVal!==""||rushVal!==""?" |":""),"Let us cut your t-shirts":cutVal,"Add an embroidered message":embVal,"Rush Production ":rushVal,_boldVariantNames:boldVariantNames.join(","),_boldVariantIds:boldVariantIds.join(","),_boldProductIds:boldProductIds.join(","),_boldVariantPrices:boldProductPrices.join(","),_boldBuilderId:`memorystitch_9a0bf1159f79c6ab0660ec422f350445_${randomNumber}`,_boldOptionLocalStorageId:key},quantity:"1",add:""};addProductToCart(key,requestData,cartObjectArray)}),window.location.href="/cart";return}function getLastLineValue(lineNumber){const lines=document.querySelectorAll(`input[name="line_${lineNumber}"]`);return lines[lines.length-1].value.trim()}function getLastSingleOptionSelectorTextContent(selectorIndex){const singleOptionSelectors=document.querySelectorAll(`.SingleOptionSelector-${selectorIndex}`);return singleOptionSelectors[singleOptionSelectors.length-1].value.trim()}const regex=/(?:\?|&)variant=(\d+)/,match=window.location.href.match(regex);match&&match[1]?variantId=match[1]:console.log("Variant ID not found");const lastFontColor=document.querySelectorAll('select[name="color"]')[document.querySelectorAll('select[name="color"]').length-1],lastFontFace=document.querySelectorAll('select[name="font"]')[document.querySelectorAll('select[name="font"]').length-1],newCompRegPrice=document.querySelectorAll(".price-item.price-item--regular")[document.querySelectorAll(".price-item.price-item--regular").length-1].textContent.trim(),newCompSalePrice=document.querySelectorAll(".price-item.price-item--sale")[document.querySelectorAll(".price-item.price-item--sale").length-1].textContent.trim();if(cartObjectArray[cartLength]={projectName:lastProjectName.value?.trim()||"Untitled Project",cutShirt:lastCutTshirt.checked,embroidered:lastEmbroideredMessage.checked,lineOne:getLastLineValue(1),lineTwo:getLastLineValue(2),lineThree:getLastLineValue(3),rushProduction:lastRushProduction.checked,price:window.toggleRegular===!0?newCompRegPrice:newCompSalePrice,panelSize:getLastSingleOptionSelectorTextContent(0),quiltSize:getLastSingleOptionSelectorTextContent(1),color:document.querySelectorAll(".swatch input:checked+label")[0]?.closest("div")?.getAttribute("data-value")?.trim()||"",variantId,componentNumber:Number(lastComponentId?.getAttribute("data-component-id")),fontColor:lastFontColor.value.trim(),fontFace:lastFontFace.value.trim()},await hasDuplicateProjectNames(cartObjectArray)){const validationMessage=document.createElement("div");validationMessage.classList.add("validation-message"),validationMessage.textContent="Project names must be unique.",cartObjectArray=[],document.querySelector("#AddToCart-All").before(validationMessage),e.target.closest("#AddToCart-All").classList.remove("clicked");return}e.target.closest("#AddToCart-All").querySelector("#AddToCartText-All").textContent="ADDING TO CART...",cartObjectArray.forEach((obj,index)=>{if(!obj?.variantId)return;let cutVal="",embVal="",rushVal="",boldVariantNames=[],boldVariantIds=[],boldProductIds=[],boldProductPrices=[],cutShirtPrice=document.querySelectorAll('input[name="cut_tshirts"]')[0]?.value?.replace("$","")?.replace(".","")||"0",embroideredPrice=document.querySelectorAll('input[name="embroidered_message"]')[0]?.value?.replace("$","")?.replace(".","")||"0",rushPrice=document.querySelectorAll('input[name="rush_production"]')[0]?.value?.replace("$","")?.replace(".","")||"0";if(obj.cutShirt){let cutShirtVariantValue="37578658021552",cutShirtProductValue="6093630865584";cutShirtPrice.toString()==="999"&&(cutShirtVariantValue="37125886181552",cutShirtProductValue="5965525975216"),cutVal="\u2713",boldVariantNames.push("Let us cut your t-shirts"),boldVariantIds.push(cutShirtVariantValue),boldProductIds.push(cutShirtProductValue),boldProductPrices.push(cutShirtPrice)}obj.embroidered&&(embVal="\u2713",boldVariantNames.push("Add an embroidered message"),boldVariantIds.push("15908563812418"),boldProductIds.push("1927414251586"),boldProductPrices.push(embroideredPrice)),obj.rushProduction&&(rushVal="\u2713",boldVariantNames.push("Rush Production "),boldVariantIds.push("15378342838338"),boldProductIds.push("1927414251586"),boldProductPrices.push(rushPrice));let requestData;const randomNumber=Math.floor(Math.random()*1e9)+1,key=`${obj.variantId}_${randomNumber}`;if(obj.embroidered){const data={cb_923232_534844:{option_changed:{option_key:"cb_923232_534844",value:"checked",is_priced_option:!0,target_namespace:obj.variantId}}};localStorage.setItem(key,JSON.stringify(data)),requestData={form_type:"product",utf8:"\u2713",id:obj.variantId,"option-1":obj.color,"option-2":obj.color,properties:{"Project Name":obj.projectName+(cutVal!==""||embVal!==""?" |":""),"Let us cut your t-shirts":cutVal,"Add an embroidered message":embVal,Color:obj.fontColor,Font:obj.fontFace,"Line 1":obj.lineOne,"Line 2":obj.lineTwo,"Line 3":obj.lineThree,"Rush Production ":rushVal,_boldVariantNames:boldVariantNames.join(","),_boldVariantIds:boldVariantIds.join(","),_boldProductIds:boldProductIds.join(","),_boldVariantPrices:boldProductPrices.join(","),_boldBuilderId:`memorystitch_9a0bf1159f79c6ab0660ec422f350445_${randomNumber}`,_boldOptionLocalStorageId:key},quantity:"1",add:""}}else requestData={form_type:"product",utf8:"\u2713",id:obj.variantId,"option-1":obj.color,"option-2":obj.color,properties:{"Project Name":obj.projectName+(cutVal!==""||embVal!==""||rushVal!==""?" |":""),"Let us cut your t-shirts":cutVal,"Add an embroidered message":embVal,"Rush Production ":rushVal,_boldVariantNames:boldVariantNames.join(","),_boldVariantIds:boldVariantIds.join(","),_boldProductIds:boldProductIds.join(","),_boldVariantPrices:boldProductPrices.join(","),_boldBuilderId:`memorystitch_9a0bf1159f79c6ab0660ec422f350445_${randomNumber}`,_boldOptionLocalStorageId:key},quantity:"1",add:""};addProductToCart(key,requestData,cartObjectArray)})})}addMultipleToCart();
2//# sourceMappingURL=/cdn/shop/t/66/assets/add-multiple-to-cart.js.map?v=55303818013858906201739156112

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.