Jump to content

Percentage discount in the corner of product picture


Rollaen

Recommended Posts

Hello everyone,

 

I am currently trying to figure out how to display discount as a percentage in the corner of the product picture. 

 

 

What am I basically looking for is the result of the equation:

 

((new price/old price)-1)*100

 

with numbers, new price=6155, old price=6655, discount (set in the back office)= 500

 

((12999/15999)-1)*100= -18,75% (roundup) = -18%

 

 

then somehow put this in the product corner. I have already read many similar topics without provided solution, so I suppose it may help many prestashop users.

 

 

I am enclosing a picture for imagination how should it look like (it is from one website).

 

I apologize if I overlooked some solved topic with this problem and thank in advance to anyone who might have help.

 

Rob

post-1267339-0-08346400-1478006091_thumb.jpg

Edited by Rollaen (see edit history)
Link to comment
Share on other sites

Hello everyone

I managed to get to this point (attached picture, Kč is my countrys currency. It is like $). I need an advise. How can I remove Kč. I assume it is somehow
connected to == 'amount' or convertPrice. But I have no idea.
 
Here is my code:
 

<p id="reduction_amount" {if !$product->specificPrice || $product->specificPrice.reduction_type != 'amount' || $product->specificPrice.reduction|floatval ==0} style="display:none"{/if}>{strip}
<span id="reduction_amount_display">
{if $product->specificPrice && $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|floatval !=0}
{convertPrice price=(($productPriceWithoutReduction|floatval - $productPrice|floatval) / $productPriceWithoutReduction|floatval) * 100}%
{/if}
</span>
{/strip}</p>

Thanks in advance for any help

post-1267339-0-43610200-1478464020_thumb.png

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...