Jump to content

products price in block viewed


Recommended Posts

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> {/if}

Edited by liutauras4x4 (see edit history)
  • Like 2
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.

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

  • 3 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> {/if}

 

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.

 

Hi!

 

When I use your code for Prestashop 1.6.0.8 I see prices in blockviewed, but my site logs are full of errors:

 

PHP Notice: Undefined index: out_of_stock in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3854

PHP Notice: Undefined index: id_category_default in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3873

PHP Notice: Undefined index: link_rewrite in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3874

PHP Notice: Undefined index: ean13 in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3874

PHP Notice: Undefined index: out_of_stock in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3854

PHP Notice: Undefined index: id_category_default in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3873

PHP Notice: Undefined index: link_rewrite in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/Product.php on line 3874

PHP Notice: Undefined index: ean13 in /var/www/vhosts/4/XXXXXX/webspace/httpdocs/site.com/classes/

Any ideas how to fix it please?

 

Thank you.

Edited by RussianButch (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

Maybe this help other user.

I use 1.6.0.9

I turn error reporting to on. The error will show like what RussianButch said.

 

My modification:

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

SELECT MAX(image_shop.id_image) id_image, p.id_product, il.legend, product_shop.active, pl.name, pl.description_short,

add p.price after p.id_product become:

SELECT MAX(image_shop.id_image) id_image, p.id_product, p.price, il.legend, product_shop.active, pl.name, p.price, pl.description_short,

2) after:

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

Add:

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

3) in template:

<p> {convertPrice price=$viewedProduct->price}</p>

Thats all.

  • Like 3
Link to comment
Share on other sites

  • 3 months later...
  • 4 months later...

Hi realayumi

 

 
I was wondering if you can help me out.
I am trying to follow your guide but I can't seem to find the codes you pasted. I think it's because I am using ver. 1.6.0.14 which might be different from 1.6.0.9 coding.
If you happened to upgrade to 1.6.0.14 and were still able to display prices for viewed product block, can you please help me.
 
Thanks in advance.
Paul
Link to comment
Share on other sites

  • 2 weeks later...

 

Hi realayumi

 

 
I was wondering if you can help me out.
I am trying to follow your guide but I can't seem to find the codes you pasted. I think it's because I am using ver. 1.6.0.14 which might be different from 1.6.0.9 coding.
If you happened to upgrade to 1.6.0.14 and were still able to display prices for viewed product block, can you please help me.
 
Thanks in advance.
Paul

 

 

Hello,

Already test for 1.6.0.14 same way.

 

in modules/blockviewed/blockviewed.php try to find ( you'll find only one):

SELECT MAX(image_shop.id_image)

then add:

p.price, 

right after:

SELECT MAX(image_shop.id_image) id_image, p.id_product

and the same as for my post #11

poin 2 and 3 exactly the same.

 

poin 3 for the template, make sure in folder module in theme, not in module folder.

 

D:\apache\html\yordomain.com\themes\themesname\modules\blockviewed\blockviewed.tpl

Link to comment
Share on other sites

Thank you realayumi

 

It worked nicely.

I was wondering if there is a way to display add to wishlist button below price in Viewed Products Block and New Products Block columns.

Thank you again for your help.

Sincerely

Paul

Link to comment
Share on other sites

Try adding this

	<a id="wishlist_button" href="#" onclick="WishlistCart('wishlist_block_list', 'add', '{$product.id_product|intval}', $('#idCombination').val(), document.getElementById('quantity_wanted').value); return false;" rel="nofollow"  title="{l s='Add to my wishlist' mod='blockwishlist'}">
		{l s='Add to wishlist' mod='blockwishlist'}
	</a>

But I'm not sure the function is available everywhere, you might want to check that first and eventually hook its js to the header

Link to comment
Share on other sites

Hey Nemo

I was able to make add to wishlist to display under price in products viewed block column successfully following your guide. :)

 

Next step is to trigger it as you said by hooking it.

Can you give me the matching code to hook and please tell me in which file I should add. (I have no background in coding  :( )

Thanks in advance Nemo. 

 

http://www.kocamoca.com/en/12-skincare#  running in version1.6.1.0 with default bootstrap theme.

Link to comment
Share on other sites

Hey Nemo, I just enabled debug mode but I do not get error message when I click Add to wishlist.

However, whenever I click categories in topmenu http://www.kocamoca.com/en/12-skincare I get below message.

Anywhere else except category links I don't seem to get any error message.

 

[PrestaShopDatabaseException]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN ps_manufacturer m ON (m.id_manufacturer = p.id_manufacturer) W' at line 4
 

                            SELECT m.name, 0 nbr, m.id_manufacturer

                            FROM ps_cat_restriction p JOIN
                            INNER JOIN ps_manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
                            WHERE 1
                            GROUP BY p.id_manufacturer ORDER BY m.name

at line 765 in file classes/db/Db.php

 

760.             WebserviceRequest::getInstance()->setError(500, '
 '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
761.         }
762.         elseif (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
763.         {
764.             if ($sql)
765.                 throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
766.
767.             throw new PrestaShopDatabaseException($this->getMsgError());
768.         }
769.     }
770.
Link to comment
Share on other sites

  • 1 month later...

I followed realayumi's code to display price in blockviewed and it worked.

However there is one issue. It displays original price instead of discounted price.

Is there a way to show final reduced price?

I am running on ver. 1.6.1.1 with default theme.

www.kocamoca.com

 

Thanks

Link to comment
Share on other sites

Hi Nemo1 thanks for the response.

 

 

I have codes as below and can you instruct me where to insert Product::getPriceStatic

 

in blockviewed.php

 

SELECT MAX(image_shop.id_image) id_image, p.id_product, il.legend, product_shop.active, pl.name, pl.description_short, p.price, pl.link_rewrite, cl.link_rewrite AS category_rewrite

 

Then added

 

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

 

 

in blockviewed.tpl

I added

 

<div class="viewprice">
<div> {convertPrice price=$viewedProduct->price}</div>
</div>
 
Thanks in advance.
Link to comment
Share on other sites

  • 4 months later...

You need to modify the module.

Look for 
 

foreach ($productsViewed as $productViewed)
{

Inside the loop, you need to assign features like

$obj->features = Product::getFeaturesStatic($this->context->language->id, (int)($productsImagesArray[$productViewed]['id_product']))
Link to comment
Share on other sites

  • 2 years later...

Hi,

in this code all works good:

Quote
  •  
On 29.06.2015 at 9:31 PM, cnpark70 said:

 

Hi realayumi

 

 
I was wondering if you can help me out.
I am trying to follow your guide but I can't seem to find the codes you pasted. I think it's because I am using ver. 1.6.0.14 which might be different from 1.6.0.9 coding.
If you happened to upgrade to 1.6.0.14 and were still able to display prices for viewed product block, can you please help me.
 
Thanks in advance.
Paul

 

 

Hello,

Already test for 1.6.0.14 same way.

 

in modules/blockviewed/blockviewed.php try to find ( you'll find only one):


SELECT MAX(image_shop.id_image)

then add:


p.price, 

right after:


SELECT MAX(image_shop.id_image) id_image, p.id_product

 

but how to display specific_prices?, PS 1.6x

 

Link to comment
Share on other sites

  • 9 months later...
  • 3 weeks 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...