conidig Posted May 18, 2013 Share Posted May 18, 2013 Hi guys, what kind of code i have to put to show each products price on the block viewed? Link to comment Share on other sites More sharing options...
NemoPS Posted May 20, 2013 Share Posted May 20, 2013 Hi, I'm not sure the field is grabbed in the module, so you might need to edit the swl query as well. In any case, if it is, it sould be like {formatPrice price=$product.price} Link to comment Share on other sites More sharing options...
liutauras4x4 Posted May 23, 2013 Share Posted May 23, 2013 (edited) 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 May 23, 2013 by liutauras4x4 (see edit history) 2 Link to comment Share on other sites More sharing options...
mouse1 Posted August 31, 2013 Share Posted August 31, 2013 (edited) 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 August 31, 2013 by mouse1 (see edit history) 6 Link to comment Share on other sites More sharing options...
badfreek Posted December 11, 2013 Share Posted December 11, 2013 Hello - I would like the same - to show price beside product as well but in a Randomproduct module. Anybody? best b Link to comment Share on other sites More sharing options...
vekia Posted December 11, 2013 Share Posted December 11, 2013 randomproduct ? it's not default module? can you shed some light on it? Link to comment Share on other sites More sharing options...
badfreek Posted December 11, 2013 Share Posted December 11, 2013 (edited) Sorry - it is the Blockrandomproduct module where there is the block with random products shown with product image, short and longer description, but no price. Well, I would like the price to be shown to, as well as Add to basket button... Edited December 11, 2013 by badfreek (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 11, 2013 Share Posted December 11, 2013 but it's not a default module, so no one knows about what module you're talking it's an external addon, so please share url to it, without any additional information it's almost impossbile to help Link to comment Share on other sites More sharing options...
badfreek Posted December 12, 2013 Share Posted December 12, 2013 No, it is not the default module - it is on the list Free modules in this forum (http://www.prestashop.com/forums/topic/276602-modulefree-random-product-in-left-or-right-block/). And you can see it in action on my page here. Link to comment Share on other sites More sharing options...
RussianButch Posted October 31, 2014 Share Posted October 31, 2014 (edited) 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 3873PHP 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 October 31, 2014 by RussianButch (see edit history) Link to comment Share on other sites More sharing options...
realayumi Posted November 12, 2014 Share Posted November 12, 2014 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. 3 Link to comment Share on other sites More sharing options...
Rneo Posted February 26, 2015 Share Posted February 26, 2015 Wszystko dla 1.6 jest OK wyswietla cene, tylko teraz jak dodać cene promocyjną, typ promocji, czy procent lub cenowa, itp Link to comment Share on other sites More sharing options...
cnpark70 Posted June 29, 2015 Share Posted June 29, 2015 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 More sharing options...
realayumi Posted July 11, 2015 Share Posted July 11, 2015 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 More sharing options...
cnpark70 Posted July 15, 2015 Share Posted July 15, 2015 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 More sharing options...
NemoPS Posted July 17, 2015 Share Posted July 17, 2015 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 More sharing options...
cnpark70 Posted July 20, 2015 Share Posted July 20, 2015 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 More sharing options...
NemoPS Posted July 22, 2015 Share Posted July 22, 2015 Odd, I just checked, and the method should really be there $this->context->controller->addJS(($this->_path).'js/ajax-wishlist.js'); This is used across all pages. Do you get any js error when clicking? Link to comment Share on other sites More sharing options...
cnpark70 Posted July 22, 2015 Share Posted July 22, 2015 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.nameat 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. DbCore->displayError - [line 418 - classes/db/Db.php] - [1 Arguments] DbCore->query - [line 620 - classes/db/Db.php] - [1 Arguments] DbCore->executeS - [line 2377 - modules/blocklayered/blocklayered.php] - [1 Arguments] BlockLayered->getFilterBlock - [line 687 - modules/blocklayered/blocklayered.php] - [1 Arguments] BlockLayered->hookHeader - [line 569 - classes/Hook.php] - [1 Arguments] HookCore::coreCallHook - [line 526 - classes/Hook.php] - [3 Arguments] HookCore::exec - [line 579 - classes/controller/FrontController.php] - [1 Arguments] FrontControllerCore->initContent - [line 131 - controllers/front/CategoryController.php] CategoryControllerCore->initContent - [line 180 - classes/controller/Controller.php] ControllerCore->run - [line 373 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 28 - index.php] Link to comment Share on other sites More sharing options...
NemoPS Posted July 24, 2015 Share Posted July 24, 2015 It seems your blocklayered module is bugged, is it the latest version? Link to comment Share on other sites More sharing options...
cnpark70 Posted July 27, 2015 Share Posted July 27, 2015 Yes it is the latest version 1.6.1.0 Link to comment Share on other sites More sharing options...
NemoPS Posted July 27, 2015 Share Posted July 27, 2015 No, I mean the module's version. Anyway, it's just bugged, you need to inspect that line mentioned in the error and fix accordingly Link to comment Share on other sites More sharing options...
cnpark70 Posted September 10, 2015 Share Posted September 10, 2015 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 More sharing options...
NemoPS Posted September 11, 2015 Share Posted September 11, 2015 I think it's because it gets the price straight out of the db. That is not the real price, especially if you have combos. You need to use Product::getPriceStatic http://nemops.com/prestashop-functions-3/#.VfKOyhHzrmg Link to comment Share on other sites More sharing options...
cnpark70 Posted September 11, 2015 Share Posted September 11, 2015 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 More sharing options...
NemoPS Posted September 12, 2015 Share Posted September 12, 2015 You just have to copy my example there on the site Link to comment Share on other sites More sharing options...
cnpark70 Posted September 17, 2015 Share Posted September 17, 2015 Thanks again Nemo1, Link to comment Share on other sites More sharing options...
karlangas77 Posted February 5, 2016 Share Posted February 5, 2016 hello, i need display features on block-viewed but i cant use variable $features, similiar to product.list. Any idea? Link to comment Share on other sites More sharing options...
NemoPS Posted February 5, 2016 Share Posted February 5, 2016 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 More sharing options...
Prestaraf Posted March 2, 2018 Share Posted March 2, 2018 Hi, in this code all works good: Quote Report post Posted July 11, 2015 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 More sharing options...
lipo999 Posted December 17, 2018 Share Posted December 17, 2018 Im still lost with price with reduction.... 😕 Could you someone send me here full code? I have there now: $obj->price = $productsImagesArray[$productViewed]['price']; this showing price without reduction. Thank you all Link to comment Share on other sites More sharing options...
NemoPS Posted January 3, 2019 Share Posted January 3, 2019 What's your prestashop version? Link to comment Share on other sites More sharing options...
lipo999 Posted January 3, 2019 Share Posted January 3, 2019 5 hours ago, NemoPS said: What's your prestashop version? Hello Nemo, Im using 1.6 version. Thx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now