Jump to content

[1.7.3.1] show percentage discount price


Guest

Recommended Posts

Hi, I need to see a percentage discount on the product page, but it counts me wrong.
Where am I making mistake ?
Thank you

../themes/theme_name/templates/catalog/_partials/miniatures/_partials/product-miniature-1.tpl

../themes/theme_name/templates/catalog/_partials/product-prices.tpl

{if $product.discount_type === 'percentage'}
                            <span class="badge badge-discount discount discount-percentage">-{$product.discount_percentage_absolute}</span>
                        {else}
                            <span style="color:#000; font-weight:600;font-size: 1.2em;"><!--{$product.discount_to_display}--> -{round(($product.price / $product.regular_price) * 100,2)} %</span>
                        {/if}
Link to comment
Share on other sites

  • 2 months later...

Hi
I know it is old post but I found the solution and I want share it here. Maybe someone needs it.

{if $product.discount_type === 'percentage'}
                            <span class="badge badge-discount discount discount-percentage">-{$product.discount_percentage_absolute}</span>
                        {else}
                            <span style="color:#000; font-weight:600;font-size: 1.2em;"><!--{$product.discount_to_display}--> -{round((1-$product.price/$product.regular_price)*100,2)} %</span>
                        {/if}

-{ROUND((1-$product.price/$product.regular_price)*100,2)} %

Link to comment
Share on other sites

I purpose also my solution :

-{((($product.price_without_reduction - $product.price_with_reduction)*100)/$product.price_without_reduction)|round:0}%

 

This is also a more precise calculation with a round of 0.

 

BTW this is still a bug in ps 1.7.3.4

Link to comment
Share on other sites

  • 9 months later...

Thanks pfalomo! this solve today my problem i had with quantity discount that didn't refresh on cart when i update quantity. (PS 1.7.5.1)

If it can help somebody, i replaced in my template:

\themes\*****\templates\checkout\_partials\cart-detailed-product-line.tpl

Line 45 : 
-{$product.discount_percentage_absolute}

By this line:
-{((($product.price_without_reduction - $product.price_with_reduction)*100)/$product.price_without_reduction)|round:0}%

in my product-price.tpl the $product.discount_percentage_absolute value was greatly updating with quantity, but not on the cart.

Link to comment
Share on other sites

  • 8 months later...

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