Jump to content

[SOLVED] Show percentage price reduction in product list


degga

Recommended Posts

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 by degga (see edit history)
Link to comment
Share on other sites

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>

  • Like 1
Link to comment
Share on other sites

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 by degga (see edit history)
Link to comment
Share on other sites

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%

  • Like 1
Link to comment
Share on other sites

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 by degga (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 3 years later...
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...