I’m trying to change the savings amount to percentages from dollars, and I’m having problems with it showing up correctly on the product page. I updated the price-sale.liquid, so it shows correctly on the collections pages, but when I go to the product pages it will briefly show the correct text and then when the compare at price gets updated so does the savings amount, and it updates to the $ version.
That’s Javascript tripping you Basically, on product pages you have variants and as you change your options, Javascript makes sure the prices etc. are updated accordingly in the HTML. Have a look at your Assets / theme.js.liquid for these lines
// Also update and show the product's compare price if necessary
if ( variant.compare_at_price > variant.price ) {
var priceSaving = timber.formatSaleTag( Shopify.formatMoney(variant.compare_at_price - variant.price, moneyFormat) );
// priceSaving += ' (' + ( (variant.compare_at_price - variant.price)*100/(variant.compare_at_price) ).toFixed(0) + '%)';
this.settings.selectors.$comparePrice.html("Save [$]".replace('[$]', priceSaving)).show();
} else {
this.settings.selectors.$comparePrice.hide();
}
And update priceSaving accordingly (or let me know if you need JS help).
I copied the very first code above into price-sale.liquid and it works on the category page. But to show it on product page I just cant find the code in assets.
Where do I put the second code to display on product page? I dont know where to put it
The above solution worked for me, but it only worked for product pages. It not working on home page or collection pages.
Is there any other solution to show % on other pages.
The above solution worked for me, but it only worked for product pages. It not working on the home page or collection pages.
Is there any other solution to show % on other pages?