Jump to content

How to show before-discount price in product list


zjean

Recommended Posts

Hi all,

 

I am working on a prestashop site, and see that it is possible to show that a product is on a discount, on the product list-page. (product_list.php).

It shows me the discounted price. I would like to see the price it originates from also.

I have the following code in the foreach of product (copied from the product.tpl) which does not work:

{if isset($product.reduction) && $product.reduction}
  <span class="old_price">
   {if !$priceDisplay}
    {$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
   {else}
    {$product->getPriceWithoutReduct(true, $smarty.const.NULL)}
   {/if}	 
  </span>
  {/if}

 

The template does not compile correctly: it shows one product in stead of the full page. So it looks like it failes on executing the getPriceWithoutReduct function.

 

Can anyone advise on this?

Link to comment
Share on other sites

Hi,

 

Yes this is because in product list the $product is not an object, but an array - hence the presence of $product.reduction rather than $product->reduction you might see on other template.

 

Not too sure which version you are using but something like this should point you to the right direction:

<span id="old_price_display">{convertPrice price=$product.price}</span>

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

sorry for my late reply.

When I use the code you show, I get the new price. Say my products price is reduced from €30 -> €15. Now when ?I use $product.price, i see €15. I want to show the old price (€30) too.

How to achieve that, because I don't have the propduct object to ask the old price.

Link to comment
Share on other sites

  • 2 weeks later...

This will appear only with the product with reduced price!

 

 

 

{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}

<span id="old_price_display" style="text-decoration:line-through">{convertPrice price=$product.price_without_reduction}</span> {/if}

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...
  • 2 months later...

Thanks...

 

{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
<span id="old_price_display" style="text-decoration:line-through">{convertPrice price=$product.price_without_reduction}</span> {/if}

 

It still works for 1.5.2 ... you save my day!

Link to comment
Share on other sites

  • 3 weeks later...

Thank you. It works for 1.5.3.1

 

{if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
   <span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
{/if}

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Great code! I'm using PrestaShop™ 1.4.8.3 and I used a similar code based on yours and worked fine for me:

 

{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
<span class="price-discount">{displayWtPrice p=$product.price_without_reduction}</span>
{/if}

 

This code can be placed in "product-list.tpl" but it also works for me in modules like "homefeatured.tpl".

Edited by JesseNaylor (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 3 months later...

Thank you. It works for 1.5.3.1

 

{if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
    <span id="old_price_display">{convertPrice price=$product.price_without_reduction}</span>
{/if}

 

 

Hi, 

 

Thanks for solution. This is working for me too. 

 

However, im not getting the percentage reduction display right there along with original price and reduced price. 

 

I tried copying this. But didnt work. 

 

<span id="reduction_percent_display">{if $product->specificPrice AND $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}</span>

 

Can anyone help me how to tweak it. 

 

Thanks for any suggestion.

 

PrestaFanBoy

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Hi raptor_00, I use PrestaShop™ 1.5.6.1 too, and this code is by default in product-list.tpl file, between 69 and 74 lines, looks like :

{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
	<span class="old_price">{convertPrice price=$product.price_without_reduction}</span>
{elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
	<span class="old_price">{convertPrice price=$product.price_without_reduction}</span>
{/if}
Link to comment
Share on other sites

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