Jump to content

how to display percentage discount in individual product page


chien

Recommended Posts

hi,

 

i would like to display percentage discount instead of 'SALE' on product.tpl page.

prestashop v:1.6.1.5

 

<div id="image-block" class="clearfix">
                    <div class="badges">
                        <!--{if $product->new}<span class="ico-product ico-new"><span class="ico-new">{l s='New'}</span></span>{/if}-->
                        {if $product->on_sale}
                            <span class="ico-product ico-sale"><span class="ico-sale">{l s='SALE!'}</span></span>
                            
                        {elseif $product->specificPrice && $product->specificPrice.reduction && $productPriceWithoutReduction > $productPrice}
                            <span class="ico-product ico-sale"><span class="ico-sale">{l s='SALE!'}</span></span>
                        {/if}
                    </div>

Link to comment
Share on other sites

This should already be part of the Product.tpl look in the prices section for this code.

 

 

<p id="reduction_percent" {if $productPriceWithoutReduction <= 0 || !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}>{strip}

<span id="reduction_percent_display">
{if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
</span>
{/strip}</p>
Link to comment
Share on other sites

But it display out the amount instead of percentage.

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

 

this is what in my product.tpl

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