fetch('https://api.parityvend.cloud/frontend/get-discount/<YOUR_PUBLIC_API_KEY>/')
.then((response) => response.json())
.then((data) => {
if (data.status !== "ok") {
console.error("Error fetching discount data:", data.error_msg);
}
const discountPercentage = data.discount.discount_perc;
const currencySymbol = data.currency.symbol;
const pricingPlanElements = document.querySelectorAll(".pricing-plan");
for (const planElement of pricingPlanElements) {
const originalPrice = parseFloat(planElement.dataset.originalPrice);
let adaptedPrice = originalPrice * (1 - discountPercentage);
planElement.textContent = currencySymbol + adaptedPrice.toFixed(2);
}
}).catch((error) => {
console.error("Error fetching discount data:", error);
});