// some variable setup
let id = data.item_id;
+ const items = dataStatic.items;
+ const item = items[id];
// change the data if the id is different
if (id != pastId) {
button.classList.remove("sold");
img.classList.remove("sold");
- const items = dataStatic.items;
- const item = items[id];
-
// register function to change the data when the animation is done
setTimeout(function () {
subtext.innerHTML = item.subtext;
description.innerHTML = item.description;
- let priceValue = item.origional_price * (data.discount / 100);
+ let priceValue = item.origional_price * (1 - (data.discount / 100));
if (data.bool_rounding) {
priceValue = Math.round(priceValue * 100) / 100;
price.innerHTML = `${items[id].currency}${priceValue}`;
} else {
price.innerHTML = `${priceValue}${items[id].currency}`;
- }
+ }
main.classList.remove("hide");
pastId = id;
}, 1500);
+ } else {
+ let priceValue = item.origional_price * (1 - (data.discount / 100));
+
+ if (data.bool_rounding) {
+ priceValue = Math.round(priceValue * 100) / 100;
+ }
+
+ if (items[id].prefix) {
+ price.innerHTML = `${items[id].currency}${priceValue}`;
+ } else {
+ price.innerHTML = `${priceValue}${items[id].currency}`;
+ }
}
});
});