In My Hub
In My Hub
// Configuration for Pineal Guardian Offers
const bumpPrice = 19.00;
// Elements
const bumpToggle = document.getElementById('order-bump-toggle');
const subtotalDisplay = document.getElementById('base-price-display');
const shippingDisplay = document.getElementById('shipping-display');
const totalDisplay = document.getElementById('total-display');
const productNameDisplay = document.getElementById('product-name');
const packageRadios = document.getElementsByName('package');
const formatCurrency = (amount) => '$' + amount.toFixed(2);
function updateTotal() {
let selectedPrice = 0;
let shippingCost = 0;
let selectedName = "";
// 1. Get Selected Package (Radio)
for (const radio of packageRadios) {
if (radio.checked) {
selectedPrice = parseFloat(radio.value);
shippingCost = parseFloat(radio.getAttribute('data-shipping'));
// Update Text based on selection
if (radio.value === "234") selectedName = "Pineal Guardian X (6 Bottles)";
else if (radio.value === "236") selectedName = "Pineal Guardian X (4 Bottles)";
else selectedName = "Pineal Guardian X (2 Bottles)";
break; // Stop loop once found
}
}
// 2. Update Subtotal & Shipping Text
productNameDisplay.textContent = selectedName;
subtotalDisplay.textContent = formatCurrency(selectedPrice);
if (shippingCost === 0) {
shippingDisplay.textContent = "FREE";
shippingDisplay.style.color = "#27ae60"; // Green for free
} else {
shippingDisplay.textContent = formatCurrency(shippingCost);
shippingDisplay.style.color = "#333";
}
// 3. Add Bump if Checked
let finalTotal = selectedPrice + shippingCost;
if (bumpToggle.checked) {
finalTotal += bumpPrice;
}
// 4. Update Final Total
totalDisplay.textContent = formatCurrency(finalTotal);
// Visual Pop Effect
totalDisplay.style.transform = "scale(1.05)";
setTimeout(() => totalDisplay.style.transform = "scale(1)", 200);
}
// Initialize
updateTotal();
How can I help?
How can I help?
This page allows you to get in touch with me. Whether it's general inquiries or business collaborations, I'm here to help. So please feel free to fill out the contact form, and either my team or I will get back to you as soon as possible.