Rollaen Posted November 1, 2016 Share Posted November 1, 2016 (edited) 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 Edited November 1, 2016 by Rollaen (see edit history) Link to comment Share on other sites More sharing options...
Rollaen Posted November 6, 2016 Author Share Posted November 6, 2016 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 somehowconnected 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 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