18 lines
777 B
JavaScript
18 lines
777 B
JavaScript
|
|
// .... 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
|