Artizzz Posted May 15, 2011 Share Posted May 15, 2011 How to display price in top seller block?I manage to configurate new product block but for top sellers block it doesn't work. What is the difirence about this both modules?There is the code what I used to new product block: {if isset($newproduct.show_price) && $newproduct.show_price && !isset($restricted_country_mode)}{if !$priceDisplay}{convertPrice price=$newproduct.price}{else}{convertPrice price=$newproduct.price_tax_exc}{/if} {/if} But this code doesn't work on top seller block, why?? Link to comment Share on other sites More sharing options...
uddhava Posted May 15, 2011 Share Posted May 15, 2011 How to display price in top seller block?I manage to configurate new product block but for top sellers block it doesn't work. What is the difirence about this both modules?There is the code what I used to new product block: {if isset($newproduct.show_price) && $newproduct.show_price && !isset($restricted_country_mode)}{if !$priceDisplay}{convertPrice price=$newproduct.price}{else}{convertPrice price=$newproduct.price_tax_exc}{/if} {/if} But this code doesn't work on top seller block, why?? Usually this is because certain variables are not created as a smarty variable by the php class (in this case modules/blockbestseller/blockbestseller.php). So the price variable is simply not assigned. You could try to edit the php file (!!! you are changing core module files and will loose the change when upgrading).Look for this code :$smarty->assign(array( 'best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockbestsellers.tpl'); And substitute is for this code (UNTESTED) $smarty->assign(array( 'best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'), 'product_price' => $bestseller['price'] )); return $this->display(__FILE__, 'blockbestsellers.tpl'); Then in your template file you can access the price like this: {$product_price}This is an untested example. You have to figure out if it works correctly. Dont have a good internetconnection here. Link to comment Share on other sites More sharing options...
Artizzz Posted May 15, 2011 Author Share Posted May 15, 2011 I doesn't work.I'm wondering why the code work on new product block module but don't work on best seller block. There is some big difference about those modules? Link to comment Share on other sites More sharing options...
uddhava Posted May 15, 2011 Share Posted May 15, 2011 I'm wondering why the code work on new product block module but don't work on best seller block. There is some big difference about those modules? Did you actually read my post ??I said, and i quote myselfUsually this is because certain variables are not created as a smarty variable by the php class (in this case modules/blockbestseller/blockbestseller.php). So the price variable is simply not assigned. If you dont know how Smarty works then you can find info here: http://www.smarty.net/documentationI doesn’t work. Duh? I gave you an UNTESTED example. Now you try to improve it. If you dont know how to program php, then search the forum because there are many examples there where you can learn from. Or maybe somebody else has done this before. Link to comment Share on other sites More sharing options...
Artizzz Posted May 15, 2011 Author Share Posted May 15, 2011 I discover code what displays price : {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} But the price are incorrect, BUT if I use simply {$product.price} it displays correct price, why is that? But also I can't display specific price if product has discount so I anyway need to make it like new product block. Usually this is because certain variables are not created as a smarty variable by the php class (in this case modules/blockbestseller/blockbestseller.php). So the price variable is simply not assigned. But why then in newproductblock.php there are no price variables? Link to comment Share on other sites More sharing options...
Artizzz Posted May 15, 2011 Author Share Posted May 15, 2011 Ok, I found problem! Deleted "Light" in blockbestsellers.php and the code what I used in new product block now works on top seller block. from: $bestsellers = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5); to: $bestsellers = ProductSale::getBestSales((int)($params['cookie']->id_lang), 0, 5); But I would like to know- what that line do? And if it's ok to edit that line?On first look all looks right. Link to comment Share on other sites More sharing options...
Ukoo - Guillaume Posted July 20, 2011 Share Posted July 20, 2011 Hi and thanks for your solution. But I would like to know- what that line do? And if it’s ok to edit that line? As it name suggests this function is exactly the same, but provided more information about the product (as its price)... Link to comment Share on other sites More sharing options...
Carisma Posted July 20, 2012 Share Posted July 20, 2012 incredible solution!! Link to comment Share on other sites More sharing options...
patfrat Posted March 4, 2013 Share Posted March 4, 2013 Yes ! Nice job ... getBestSales instead of getBestSalesLight ! I have just override my themes/.../modules/blockbestsellers/blockbestsellers-home.tpl And have added this to display also specific prices with prices without reduction with "text-decoration: line-through;" ... {if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE} <div class="price_without_reduction">{convertPrice price=$product.price_without_reduction}</div> {/if} Link to comment Share on other sites More sharing options...
Konrad K Posted March 21, 2013 Share Posted March 21, 2013 Great solution. Works perfectly on prestashop 1.3.1.1. Link to comment Share on other sites More sharing options...
isaiaseg Posted April 15, 2013 Share Posted April 15, 2013 maann how i can do that but on blocknewproduct ?? i mean, display the price the correct prcice?, i tried but shows me 0.00$ and that is not the actual price Link to comment Share on other sites More sharing options...
patfrat Posted April 15, 2013 Share Posted April 15, 2013 (edited) maann how i can do that but on blocknewproduct ?? i mean, display the price the correct prcice?, i tried but shows me 0.00$ and that is not the actual price What is your code ? Have you tried this ? {convertPrice price=$product.price_without_reduction} I use a template override in my theme folder/modules /homefeatured/homefeatured.tpl to display the specific price and the price without reduction {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <div class="price_container"> {if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE} <div style="margin-top:-10px;color:#666;font-size:.8em;font-weight:normal;text-align:right;text-decoration: line-through;">{convertPrice price=$product.price_without_reduction}</div> {/if} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} </div> {/if} Edited April 15, 2013 by patfrat (see edit history) Link to comment Share on other sites More sharing options...
trevorgilligan Posted January 9, 2015 Share Posted January 9, 2015 on my shop vouchoff.com/shop , when i click best sellers, it shows products, but the add to cart button, new label, sale label all gone, any one how to get thes back. add to cart button everywhere else, trev 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