Jump to content

How to display product price in the Viewed products block


snco

Recommended Posts

Hello All,

I need some help here…I want to display the product price for each viewed product in the ‘Viewed products’ block.
This is my site: http://stepcare.eu/shop

If you look at the viewed products block you can see there is already price showing, but it is the special product price, because I copied some lines of code from the ‘specials block’.
I can’t figure it out how to display the final product price tax included, not the special price as it is at the moment.

Please, give some help!

Alex

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...
  • 5 months later...
  • 10 months later...

Hello,

i am using 1.5.3.1 and standart blockviewd module. It is done in this way.

Added blockviewed.php around line 138:

 

$product_properties = Product::getProductProperties($params['cookie']->id_lang,array('id_product' => $obj->id),null);
$obj->price = $product_properties['price'];
$obj->price_without_reduction = $product_properties['price_without_reduction'];
$obj->specific_prices = $product_properties['specific_prices'];
$obj->static_token = Tools::getToken(false);

 

Also in blockviewed.tpl in theme folder:

<p> {convertPrice price=$viewedProduct->price}</p>
   {if $viewedProduct->specific_prices AND $viewedProduct->specific_prices.reduction_type == 'percentage'}
 <p> {convertPrice price=$viewedProduct->price_without_reduction}</p>
 <p> -{$viewedProduct->specific_prices.reduction*100}% </p>

  • Like 2
Link to comment
Share on other sites

Hello,

i am using 1.5.3.1 and standart blockviewd module. It is done in this way.

Added blockviewed.php around line 138:

 

$product_properties = Product::getProductProperties($params['cookie']->id_lang,array('id_product' => $obj->id),null);
$obj->price = $product_properties['price'];
$obj->price_without_reduction = $product_properties['price_without_reduction'];
$obj->specific_prices = $product_properties['specific_prices'];
$obj->static_token = Tools::getToken(false);

 

Also in blockviewed.tpl in theme folder:

<p> {convertPrice price=$viewedProduct->price}</p>
{if $viewedProduct->specific_prices AND $viewedProduct->specific_prices.reduction_type == 'percentage'}
 <p> {convertPrice price=$viewedProduct->price_without_reduction}</p>
 <p> -{$viewedProduct->specific_prices.reduction*100}% </p>

 

it works fine, thanks for your solution i checked it in my demo store and it works well

Link to comment
Share on other sites

  • 3 months later...

Thank you liutauras4x4 for the code. It helped big time! It didn't work for me fully for some reason (images of viewed products appeared in viewed block, but disappeared from blocknewproducts and from product list), so I adjusted the code a bit...

 

1) I opened modules/blockviewed/blockviewed.php and found this code:

 

$obj->category_rewrite = $productsImagesArray[$productViewed]['category_rewrite'];

 

2) After that code I added this:

 

$product_properties = Product::getProductProperties($params['cookie']->id_lang,array('id_product' => $obj->cover),null);
$obj->price = $product_properties['price'];

 

3) I opened themes/default/modules/blockviewed/blockviewed.tpl and added the following code (I placed it at the very end before the last "</li>" ) :

 

<div class="viewprice">	  
<div> {convertPrice price=$viewedProduct->price}</div>
</div>  

 

Now all images display correctly in all parts of my shop + I have the final price in my viewed block (I mean price after reduction which I wanted). If you also want to include original price and discount in %, use the second code posted by liutauras4x4, I tried it and it worked.

 

Hope this helps someone. ;-)

 

PS: I'm using Prestashop 1.5.4.0.

Link to comment
Share on other sites

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