-

Ground muscadine grape seed provides a convenient, whole-food source of naturally occurring polyphenols and antioxidant support
(function () {
const formBox =
document.getElementById("nat-prl-muscadine-grape-seed-capsules-form");
if (!formBox) {
return;
}
const packageSelect =
formBox.querySelector(
"#nat-prl-muscadine-grape-seed-capsules-package"
);
const productPriceField =
formBox.querySelector(
"#nat-prl-muscadine-grape-seed-capsules-productpr"
);
const priceDisplay =
formBox.querySelector(
"#nat-prl-muscadine-grape-seed-capsules-price"
);
const addToCartButton =
formBox.querySelector(
"#nat-prl-muscadine-grape-seed-capsules-add-to-cart"
);
const deliveryInputs =
formBox.querySelectorAll(
'input[name="nat-prl-muscadine-grape-seed-capsules-delivery"]'
);
/* ---------------------------------------------------------
Product identification
--------------------------------------------------------- */
const productName =
"Nature's Pearl Premium Muscadine Grape Seed";
/* ---------------------------------------------------------
Package options
--------------------------------------------------------- */
const packages = {
one: {
sku: "USNP000001",
description: "(1) bottle / 60 capsules",
price: "32.95"
},
two: {
sku: "USNP000001",
description: "(2) bottles / 60 capsules each",
price: "65.90"
},
three: {
sku: "USNP000001",
description: "(3) bottles / 60 capsules each",
price: "98.85"
},
four: {
sku: "USNP000001",
description: "(4) bottles / 60 capsules each",
price: "131.80"
}
};
/* ---------------------------------------------------------
Get selected delivery option
--------------------------------------------------------- */
function selectedDelivery() {
const selected =
formBox.querySelector(
'input[name="nat-prl-muscadine-grape-seed-capsules-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;
}
/*
Cart description contains:
Product
+ quantity/package description
+ manufacturer SKU
+ selected delivery schedule
Price stays the same whether the customer
chooses one-time purchase or autoship.
*/
const description =
productName +
", " +
selectedPackage.description +
", SKU " +
selectedPackage.sku +
", " +
deliveryDescription(delivery);
/*
Mals productpr format:
full description, :price
*/
productPriceField.value =
description +
", :" +
selectedPackage.price;
/* Display selected price */
priceDisplay.textContent =
"$" + selectedPackage.price;
priceDisplay.classList.remove(
"lwf-price-prompt"
);
/* Enable Add to Cart */
addToCartButton.disabled = false;
addToCartButton.textContent =
"Add to Cart";
}
/* ---------------------------------------------------------
Event listeners
--------------------------------------------------------- */
deliveryInputs.forEach(
function (input) {
input.addEventListener(
"change",
updateSelection
);
}
);
packageSelect.addEventListener(
"change",
updateSelection
);
/* ---------------------------------------------------------
Initialize
--------------------------------------------------------- */
updateSelection();
})();