diff --git a/assets/theme.js b/assets/theme.js new file mode 100644 index 0000000..e579e73 --- /dev/null +++ b/assets/theme.js @@ -0,0 +1,18 @@ +// .... find this line +const selectedVariant = productJson.variants.find(variant => variant.id === variantId) + +// ... then paste this right below +const discountPercentage = productJson.discount_percentage || 0; +var selectedVariant_compare_at_price = selectedVariant.compare_at_price; +var selectedVariant_price = selectedVariant.price; + +if(discountPercentage > 0.1){ + selectedVariant_price = selectedVariant.price * (1.0 - discountPercentage); + selectedVariant_compare_at_price = selectedVariant.price; + + if(selectedVariant.compare_at_price > selectedVariant_compare_at_price){ + selectedVariant_compare_at_price = selectedVariant.compare_at_price; + } +} + +//... replace selectedVariant.price with selectedVariant_price, and replace selectedVariant_compare_price \ No newline at end of file