const formContainer=document.querySelector(".product-form[data-product]"),productData=JSON.parse(formContainer.dataset.product),productForm=document.querySelector('form[data-type="add-to-cart-form"]');function updateDiscounts(){const selectedVariant=findSelectedVariant(),sellingPlanId=document.querySelector('input[name="selling_plan"]:checked').value,availableSellingPlanAllocations=selectedVariant.selling_plan_allocations;let price=selectedVariant.price,qty=1;if(availableSellingPlanAllocations&&availableSellingPlanAllocations.length>0&&sellingPlanId){const selectedPlan=availableSellingPlanAllocations.find(plan=>plan.selling_plan_id===parseInt(sellingPlanId));selectedPlan&&(price=selectedPlan.price,qty=selectedPlan.compare_at_price/selectedVariant.price)}if(price){const discount=(selectedVariant.compare_at_price*qty-price)/100;document.querySelector(".discount-box").innerText="SAVE "+new Intl.NumberFormat("en-US",{style:"currency",currency:"RM",minimumFractionDigits:2}).format(discount),document.querySelector(".final-price-item").innerText=new Intl.NumberFormat("en-US",{style:"currency",currency:"RM",minimumFractionDigits:2}).format(price/100),document.querySelector(".compare-price").innerText=new Intl.NumberFormat("en-US",{style:"currency",currency:"RM",minimumFractionDigits:2}).format(selectedVariant.compare_at_price*qty/100)}console.log(sellingPlanId),sellingPlanId==="3181150436"?document.querySelector(".appstle_subscribe_save_text span.font-light").innerText="+$15 shipping":sellingPlanId==="3181117668"?document.querySelector(".appstle_subscribe_save_text span.font-light").innerText="+$10 shipping":sellingPlanId&&(document.querySelector(".appstle_subscribe_save_text span.font-light").innerText="free shipping")}const findSelectedVariant=function(){const selectedVariantId=parseInt(productForm.querySelector('[name="id"]').value);let selectedVariant;for(let i=0;i0&&mutation.addedNodes.forEach(node=>{node.id&&node.id.indexOf("appstle")>-1&&updateDiscounts()})});observer.observe(productForm,{childList:!0,subtree:!0}),setTimeout(function(){observer.disconnect()},5e3); //# sourceMappingURL=/cdn/shop/t/1/assets/product.js.map