Showing the single result
-

Body Balance™ and OsteoProCare® together in four money-saving pack options
(function () {
const formBox =
document.getElementById("lwf-baseline-form");
if (!formBox) {
return;
}
const packageSelect =
formBox.querySelector("#baseline-package");
const productPriceField =
formBox.querySelector("#baseline-productpr");
const priceDisplay =
formBox.querySelector("#baseline-price");
const addToCartButton =
formBox.querySelector("#baseline-add-to-cart");
const deliveryInputs =
formBox.querySelectorAll(
'input[name="baseline-delivery"]'
);
/* ---------------------------------------------------------
Package options
--------------------------------------------------------- */
const packages = {
baseline: {
name: "Baseline",
sku: "USLF000021V",
description: "2 Body Balance + 1 OsteoProCare",
price: "104.95"
},
plus: {
name: "Baseline Plus",
sku: "USLF080266",
description: "4 Body Balance + 1 OsteoProCare",
price: "156.95"
},
family: {
name: "Baseline Family",
sku: "USLF000020V",
description: "4 Body Balance + 2 OsteoProCare",
price: "194.95"
},
ultra: {
name: "Baseline Ultra",
sku: "USLF080268",
description: "8 Body Balance + 2 OsteoProCare",
price: "277.95"
}
};
/* ---------------------------------------------------------
Get selected delivery option
--------------------------------------------------------- */
function selectedDelivery() {
const selected =
formBox.querySelector(
'input[name="baseline-delivery"]:checked'
);
return selected ? selected.value : "";
}
/* ---------------------------------------------------------
Standard delivery wording
--------------------------------------------------------- */
function deliveryDescription(delivery) {
if (delivery === "monthly") {
return "autoship monthly";
}
if (delivery === "two-months") {
return "autoship every 2 months";
}
return "one-time purchase";
}
/* ---------------------------------------------------------
Build complete Mals cart description and price
--------------------------------------------------------- */
function updateSelection() {
const packageKey =
packageSelect.value;
const delivery =
selectedDelivery();
if (!packageKey) {
productPriceField.value = "";
priceDisplay.textContent =
"(Price will show when you make your selection)";
priceDisplay.classList.add(
"lwf-price-prompt"
);
addToCartButton.disabled = true;
addToCartButton.textContent =
"Add to Cart";
return;
}
const selectedPackage =
packages[packageKey];
if (!selectedPackage) {
return;
}
const description =
selectedPackage.name +
", " +
selectedPackage.description +
", SKU " +
selectedPackage.sku +
", " +
deliveryDescription(delivery);
productPriceField.value =
description +
", :" +
selectedPackage.price;
priceDisplay.textContent =
"$" + selectedPackage.price;
priceDisplay.classList.remove(
"lwf-price-prompt"
);
addToCartButton.disabled = false;
addToCartButton.textContent =
"Add to Cart";
}
/* ---------------------------------------------------------
Event listeners
--------------------------------------------------------- */
deliveryInputs.forEach(
function (input) {
input.addEventListener(
"change",
updateSelection
);
}
);
packageSelect.addEventListener(
"change",
updateSelection
);
/* ---------------------------------------------------------
Initialize
--------------------------------------------------------- */
updateSelection();
})();