PageSourceSearch

https://www.thebodyshop.com/cdn/shop/t/100/assets/selling-plans-in…?v=106895225984370947211777564736

js thebodyshop.com collected 2026-09-24 15:20:30 UTC 8,048 bytes, 2 lines download raw bytes

1const hiddenClass="selling_plan_theme_integration--hidden";class SellingPlansWidget{constructor(sellingPlansWidgetContainer){this.sellingPlansWidgetContainer=sellingPlansWidgetContainer,this.sellingPlanWrapper=document.querySelector(".selling_plan_wrapper"),this.mainSubsWrapper=document.querySelector(".main-subs-wrapper"),this.init(),this.connectedCallback()}init(){this.appendSellingPlanInputs(),this.updateSellingPlanInputsValues()}connectedCallback(){this.listenToSellingPlanFormRadioButtonChange(),this.listenToSubscriptionChange(),document.addEventListener("theme:variant:change",this.onVariantChanged.bind(this)),this.addToCartForms.forEach(form=>{form.addEventListener("submit",this.onFormSubmit.bind(this))}),this.refresh()}disconnectedCallback(){document.removeEventListener("theme:variant:change",this.onVariantChanged.bind(this)),this.addToCartForms.forEach(form=>{form.removeEventListener("submit",this.onFormSubmit.bind(this))})}onVariantChanged(event){event.detail&&event.detail.variant&&(this.refresh(event.detail.variant.id),event.detail.variant.available&&event.detail.variant.selling_plan_allocations.length>0?this.mainSubsWrapper.classList.remove("hidden"):this.mainSubsWrapper.classList.add("hidden"))}onFormSubmit(event){this.updateSellingPlanInputsValues()}refresh(variantId){variantId&&this.variantIdInput&&this.variantIdInput.value!==variantId&&(this.variantIdInput.value=variantId),this.handleSellingPlanFormVisibility(),this.updateSellingPlanInputsValues(),this.listenToSellingPlanFormRadioButtonChange(),this.updatePrice()}get sectionId(){return this.sellingPlansWidgetContainer.getAttribute("data-section-id")}get shopifySection(){return document.querySelector(`#shopify-section-${this.sectionId}`)}get variantIdInput(){return this.addToCartForms[1]?.querySelector('input[name="id"]')||this.addToCartForms[1]?.querySelector('select[name="id"]')||this.addToCartForms[0].querySelector('input[name="id"]')||this.addToCartForms[0].querySelector('select[name="id"]')}get comparedAtPrice(){return this.shopifySection.querySelector(".price__sale")}get visibleSellingPlanForm(){return this.shopifySection.querySelector(`section[data-variant-id^="${this.variantIdInput.value}"]`)}get isVariantAvailable(){return this.selectedPurchaseOption.getAttributeNames().includes("disabled")}get sellingPlanInput(){return this.shopifySection.querySelector(".selected-selling-plan-id")}get addToCartForms(){return this.shopifySection.querySelectorAll('[action*="/cart/add"]')}appendSellingPlanInputs(){this.addToCartForms.forEach(addToCartForm=>{addToCartForm.appendChild(this.sellingPlanInput.cloneNode())})}showSellingPlanForm(sellingPlanFormForSelectedVariant){sellingPlanFormForSelectedVariant?.classList?.remove(hiddenClass)}hideSellingPlanForms(sellingPlanFormsForUnselectedVariants){sellingPlanFormsForUnselectedVariants.forEac
1h(element=>{element.classList.add(hiddenClass)})}handleSellingPlanFormVisibility(){const sellingPlanFormForSelectedVariant=this.shopifySection.querySelector(`section[data-variant-id="${this.variantIdInput.value}"]`),sellingPlanFormsForUnselectedVariants=this.shopifySection.querySelectorAll(`.selling_plan_theme_integration:not([data-variant-id="${this.variantIdInput.value}"])`);this.showSellingPlanForm(sellingPlanFormForSelectedVariant),this.hideSellingPlanForms(sellingPlanFormsForUnselectedVariants)}listenToSubscriptionChange(){this.activateSubscriptionInput.addEventListener("change",evt=>{this.toggleSubscription(evt),this.listenToSellingPlanFormRadioButtonChange()})}get priceElement(){return document.querySelector("[data-product-price]")}get addToCartButtons(){return this.shopifySection?.querySelectorAll("[data-add-to-cart]")??[]}formatPriceWithoutCurrency(formattedPrice){return formattedPrice?String(formattedPrice).replace(/\s/g,"").replace(/[^\d.,-]/g,""):""}get compareAtPriceValue(){return document.querySelector("[data-compare-price]")}get activateSubscriptionInput(){return this.shopifySection.querySelector(".activate-subscription")}get sellingPlanRadioButton(){return this.shopifySection.querySelectorAll(".selling_plan--radio")}get savingAmountElement(){return this.visibleSellingPlanForm.querySelector(".saving-amount")}updatePrice(){const selectedRadio=this.shopifySection.querySelector(`section[data-variant-id^="${this.variantIdInput.value}"]`)?.querySelector('input[type="radio"]:checked'),currentPrice=selectedRadio?.dataset?.variantPrice;if(currentPrice&&this.addToCartButtons.forEach(btn=>{const label=btn.querySelector(".btn__text");label&&(label.innerHTML="ADD TO BAG - "+currentPrice);const totalEl=btn.querySelector(".custom-atc-total");if(totalEl){const priceNoCurrency=this.formatPriceWithoutCurrency(currentPrice);priceNoCurrency&&(totalEl.textContent=priceNoCurrency.replace(".00",""),totalEl.setAttribute("data-price",priceNoCurrency))}}
1),selectedRadio){if(this.savingAmountElement){const savingAmount=parseFloat(selectedRadio?.dataset?.regularPrice)-parseFloat(selectedRadio?.dataset?.allocationRawPrice);this.savingAmountElement.innerHTML="Save \xA3"+(savingAmount/100).toFixed(2)}this.updatePDPPrice(),this.updatePricePerMl()}}updatePDPPrice(){const currentPrice=this.visibleSellingPlanForm?.querySelector('input[type="radio"]:checked')?.dataset?.variantPrice;currentPrice&&(this.priceElement.innerHTML=currentPrice.replace(".00",""))}updatePricePerMl(){const pricePerMlHolder=document.querySelector("[data-price-per-ml]");if(!pricePerMlHolder)return;const sizeType=this.visibleSellingPlanForm?.dataset?.variantSizeType,sizeValue=parseFloat(this.visibleSellingPlanForm?.dataset?.variantSizeValue||0),currentPrice=this.shopifySection.querySelector(`section[data-variant-id^="${this.variantIdInput.value}"]`)?.querySelector('input[type="radio"]:checked')?.dataset?.variantPriceRaw;if(!sizeType||!sizeValue){pricePerMlHolder.textContent="";return}let comparisonAmount=100;sizeType.charAt()=="g"&&(comparisonAmount=10);const amountInComparison=comparisonAmount/sizeValue,pricePerComparison=currentPrice*amountInComparison,displayPrice=formatMoney(pricePerComparison,theme.moneyFormat);pricePerMlHolder.textContent=`${displayPrice.replace(".00","")} Per ${comparisonAmount}${sizeType}`}toggleSubscription(evt){evt.target.checked?document.querySelectorAll(".selling_plan_wrapper").forEach(element=>{element.classList.remove("hidden"),element.querySelector(".selling_plan--radio").checked=!element.querySelector(".selling_plan--radio").checked,this.handleRadioButtonChange(element.querySelector(".selling_plan--radio"))}):document.querySelectorAll(".selling_plan_wrapper").forEach(element=>{element.classList.add("hidden")}),this.visibleSellingPlanForm.querySelector(".selling_plan_wrapper").classList.contains("hidden")&&(this.visibleSellingPlanForm.querySelectorAll(".selling_plan--radio").forEach(radio=>{radio.checked=!1}),document.querySelectorAll(".selling_plan--one-time").forEach(radio=>{radio.checked=!0,this.handleRadioButtonChange(radio)}))}get sellingPlanInputs(){return this.shopifySection.querySelectorAll(".selected-selling-plan-id")}updateSellingPlanInputsValues(){this.sellingPlanInputs.forEach(sellingPlanInput=>{sellingPlanInput.value=this.sellingPlanInputValue})}get sellingPlanInputValue(){return this.selectedPurchaseOption?.dataset.sellingPlanId??null}get selectedPurchaseOption(){return this.visibleSellingPlanForm?.querySelector('input[type="radio"]:checked')}set selectedPurchaseOption(selectedPurchaseOption){this._selectedPurchaseOption=selectedPurchaseOption}handleRadioButtonChange(selectedPurchaseOption){this.updateSellingPlanInputsValues(),this.updatePrice()}listenToSellingPlanFormRadioButtonChange(){this.visibleSellingPlanForm?.querySelectorAll('input[type="radio"]').forEach(radio=>{radio.addEventListener("change",event=>{this.handleRadioButtonChange(event.target)})})}}document.querySelectorAll(".selling_plan_app_container").forEach(sellingPlansWidgetContainer=>{new SellingPlansWidget(sellingPlansWidgetContainer)});
2//# sourceMappingURL=/cdn/shop/t/100/assets/selling-plans-integration.js.map?v=106895225984370947211777564736

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.