degga Posted April 1, 2016 Share Posted April 1, 2016 (edited) Hello to everybody! I'm trying to show the percentage price reduction in the product list page... It show the percentage but it doesn't rounds the amount ... it shows 4980% and not 50%. Can you help me? Thanks for your time! Best regards Edited April 4, 2016 by degga (see edit history) Link to comment Share on other sites More sharing options...
SupportPS Posted April 1, 2016 Share Posted April 1, 2016 Hello. Go to your theme folder and open file product.tpl in notepad++ change: <span id="reduction_percent_display"> {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}</span> to: <span id="reduction_percent_display"> {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{($product->specificPrice.reduction*100)|round:0}%{/if}</span> 1 Link to comment Share on other sites More sharing options...
degga Posted April 1, 2016 Author Share Posted April 1, 2016 (edited) Hi! First of all thank you for your reply! Your modify is about product.tpl and I did it ... but I'm interested to show it in the product-list.tpl and there doesn't work ... I solved inserting this line of code -{($product.specific_prices.reduction*100)/100}% but anyway doesn't rounds ... he gives me back -49.18% ... but should be -50% ... ::::: UPDATE :::::: The percentage calculated is wrong ... Edited April 1, 2016 by degga (see edit history) Link to comment Share on other sites More sharing options...
SupportPS Posted April 1, 2016 Share Posted April 1, 2016 Open product-list.tpl correct: <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span> to: <span class="price-percent-reduction">-{($product.specific_prices.reduction * 100)|round:0}%</span> If 49.50% or higher, then rounded to 50%If 49.49% or less, then rounded to 49% 1 Link to comment Share on other sites More sharing options...
degga Posted April 4, 2016 Author Share Posted April 4, 2016 (edited) Your way is ok, but the percentage calculated is still wrong ... I don't know why! I solved writing a line of code to calculate the right percentage : <span class="price-percent-reduction"> -{((($product.price_without_reduction-$product.price)*100)/$product.price_without_reduction)|round:0}% </span> Thanks anyway for your time!!! I really appreciate it! Edited April 4, 2016 by degga (see edit history) 1 Link to comment Share on other sites More sharing options...
MortenH Posted September 24, 2019 Share Posted September 24, 2019 On 4/4/2016 at 12:41 PM, degga said: Your way is ok, but the percentage calculated is still wrong ... I don't know why! I solved writing a line of code to calculate the right percentage : <span class="price-percent-reduction"> -{((($product.price_without_reduction-$product.price)*100)/$product.price_without_reduction)|round:0}% </span> Thanks anyway for your time!!! I really appreciate it! Thank you so much, fixed my wrong calculations. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now