Jump to content

[SOLVED] How do I display the original price with the sale price in category view?


Recommended Posts

Currently, when I click on a category, it will only display the final price of the item. If the item is on sale, it will show the sale price which is the final retail price.

I would like it to show the sale price if the item is on sale and the original price with a strikethrough indicating that the item is on sale.

I have found the line of code where I need to add some PHP, but I do not now enough PHP to know what to insert there.

The line I mean is located in the product-list.tpl file and the line is:

{displayWtPrice p=$product.price}{l s='View'}



I assume it has to look something like this, where 'pretaxretailprice' is a wild guess:

{displayWtPrice p=$product.price} SALE! {displayWtPrice p=$product.pretaxretailprice}{l s='View'}



I know I just need to add some PHP before the tag, but what is the code to get the products' Pre-tax retail price or retail price before tax (tax is included in my shop)???

I don't really require an IF statement testing if the item is on sale, I will only add the code to the prices-drop.tpl, not in products-list.tpl.

Please see screenshot for what I mean. The left image is how the shop currently displays the prices. The right image shows how I would like it to look like.

Please help!!!

Link to comment
Share on other sites

Thanks for all the awesome replies!!!! Lucky I am able to figure stuff out on my own or PrestaShop would not be a viable eCommerce solution for me.

This only applies to the Black & White theme I am using, but the general idea is the same for all themes.

In the product-list.tpl replace this line:

{displayWtPrice p=$product.price}{l s='View'}



with this line:

{if $product.price_without_reduction != $product.price}{displayWtPrice p=$product.price_without_reduction} SALE! {/if}{displayWtPrice p=$product.price}{l s='View'}



This will display the original price first, with the new sale price next to it... Since there is an IF statement, this will only display the strike through original price, if the item is actually on sale. If the item price is the standard price, it won't display the element between the if statement.

To achieve strikethrough text etc. you have to either create a local CSS rule or create a class in global.css and add your styling there. If that's too difficult, you shouldn't be messing with the code. I'd recommend Firebug to test it live.


To achieve the same result in the prices-drop.tpl (works also with new arrivals and all the other product pages that are not part of product-list.tpl), find the following line:

{displayWtPrice p=$product.price}{l s='View'}



and replace it with this line:

{displayWtPrice p=$product.price_without_reduction} SALE! {displayWtPrice p=$product.price}{l s='View'}



Again, you need to add CSS to "{displayWtPrice p=$product.price_without_reduction}" in order to achieve a strikethrough, depending on your CSS, you will need to make sure margins, padding, etc. is accounted for. If this is too difficult for you, learn how to use Firebug, makes CSS changes sooooo much easier.

Link to comment
Share on other sites

Wow dude, thanks so much for your help! Would have been screwed without you!

To make it easier for noobs, this line:

{displayWtPrice p=$product.price_without_reduction}



will display the original price of items before the sale deduction...

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 2 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...