Add theme .js for price change when variant change on collection
Add theme .js for price change when variant change on collection
This commit is contained in:
18
assets/theme.js
Normal file
18
assets/theme.js
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user