Showing the single result
-

A convenient liquid sleep-support formula combining melatonin with chamomile and valerian extracts to support restful sleep without pills or gummies
(function () {
const formBox =
document.getElementById("lwf-bio-nite-form");
if (!formBox) {
return;
}
const packageSelect =
formBox.querySelector("#bn-package");
const productPriceField =
formBox.querySelector("#bn-productpr");
const priceDisplay =
formBox.querySelector("#bn-price");
const addToCartButton =
formBox.querySelector("#bn-add-to-cart");
const deliveryInputs =
formBox.querySelectorAll(
'input[name="bn-delivery"]'
);
/* ---------------------------------------------------------
Product identification
--------------------------------------------------------- */
const productName =
"BioNite Holistic Sleep Support";
/* ---------------------------------------------------------
Package options
--------------------------------------------------------- */
const packages = {
one: {
sku: "USBI000006",
description: "(1 set) 2 bottles, 2 fl. oz. each",
price: "37.90"
},
two: {
sku: "USBI000006",
description: "(2 sets) 4 bottles, 2 fl. oz. each",
price: "75.80"
},
three: {
sku: "USBI000006",
description: "(3 sets) 6 bottles, 2 fl. oz. each",
price: "113.70"
},
four: {
sku: "USBI000006",
description: "(4 sets) 8 bottles, 2 fl. oz. each",
price: "151.60"
}
};
/* ---------------------------------------------------------
Get selected delivery option
--------------------------------------------------------- */
function selectedDelivery() {
const selected =
formBox.querySelector(
'input[name="bn-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();
/* No quantity selected yet */
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 =
productName +
", " +
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();
})();