Lpeek Posted May 29, 2010 Share Posted May 29, 2010 I have a product that changes price depending on what attributes the user selects. Is there a way to display the price as: "from £##.##" in the category listing and the product page so my customers don't think all sizes are one price? Link to comment Share on other sites More sharing options...
rocky Posted May 30, 2010 Share Posted May 30, 2010 You'll need to edit change line 18 of product-list.tpl in your theme's directory (in PrestaShop v1.3) from: {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} to: {l s='from'} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} Link to comment Share on other sites More sharing options...
Lpeek Posted May 30, 2010 Author Share Posted May 30, 2010 Cheers rocky! But that will display 'from' for everything wont it? I'd like to have 'from' show only for the products that have more than one price attribute? Link to comment Share on other sites More sharing options...
rocky Posted May 30, 2010 Share Posted May 30, 2010 You are right. In that case, try: {if $product.id_product_attribute}{l s='from'}{/if} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} I haven't tested it, but I think it should work. Link to comment Share on other sites More sharing options...
Lpeek Posted May 30, 2010 Author Share Posted May 30, 2010 thanks again rocky! I appreciate your help! It's on the right track, but again, the products attributes dont always change the price... its only on certain items/attributes. I could see it being a bit complicated... to show exactly what I mean...I have a sweatshirt which costs £15 and it's available in sizes S, M, L, XL and XXL, but the XXL size costs £1 more. All products will have sizes S, M and L, but not every product will have XXL, so not all products have more than 1 price, so really I need to work on something that finds if an attribute alters the price, and if it does, then display the from string.I think that makes sense... But like I said, it sounds like it could be quite complex Link to comment Share on other sites More sharing options...
domino internet Posted June 7, 2010 Share Posted June 7, 2010 Hi,I need to do the same, but on Prestashop 1.2.5, where the products-list.tpl is different from the one mentioned in this thread before: {if $product.on_sale} {l s='On sale!'} {elseif ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product.reduction_from))} {l s='Price lowered!'} {/if} {if !$priceDisplay || $priceDisplay == 2} {convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if}{/if} {if $priceDisplay} {convertPrice price=$product.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx'}{/if}{/if} {if ($product.allow_oosp OR $product.quantity > 0) && $product.customizable != 2} {l s='Add to cart'}{else} Can you please tell me what to change so I can display a "From:" on those products with various prices?Regards,Jose Link to comment Share on other sites More sharing options...
rocky Posted June 8, 2010 Share Posted June 8, 2010 Just make the same change I did above to both the prices: {if $product.on_sale} {l s='On sale!'} {elseif ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product.reduction_from))} {l s='Price lowered!'} {/if} {if !$priceDisplay || $priceDisplay == 2} {if $product.id_product_attribute}{l s='from'}{/if} {convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if}{/if} {if $priceDisplay} {if $product.id_product_attribute}{l s='from'}{/if} {convertPrice price=$product.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx'}{/if}{/if} {if ($product.allow_oosp OR $product.quantity > 0) && $product.customizable != 2} {l s='Add to cart'}{else} Link to comment Share on other sites More sharing options...
domino internet Posted June 9, 2010 Share Posted June 9, 2010 Rocky,That was very helpful.We were also able to include the "FROM" ("desde" in Spanish) into the SPECIALS (OFERTAS), NEW PRODUCTS (NOVEDADES) module and the FEATURED PRODUCTS block on the Home Page.You can see them here: http://www.pescashop.com/index.phpThe only block where we couldn't put it in was the BEST SELLERS block (LO MAS VENDIDO).We tried with this code but it doesn't recognize it: {if $id_product.id_product_attribute } {l s='desde'}{/if} Would you know what has to be changed in it to work in this block?Thanks in advance!Jose Link to comment Share on other sites More sharing options...
rocky Posted June 9, 2010 Share Posted June 9, 2010 You need to change lines 107-110 of the getBestSalesLight function in classes/ProductSale.php from: SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, i.`id_image`, il.`legend`, ps.`quantity` AS sales, p.`ean13`, cl.`link_rewrite` AS category FROM `'._DB_PREFIX_.'product_sale` ps LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).') to: SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, pa.`id_product_attribute`, i.`id_image`, il.`legend`, ps.`quantity` AS sales, p.`ean13`, cl.`link_rewrite` AS category FROM `'._DB_PREFIX_.'product_sale` ps LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) Then you can use the following in blockbestsellers.tpl: {$product.id_product_attribute} Link to comment Share on other sites More sharing options...
domino internet Posted June 9, 2010 Share Posted June 9, 2010 WOW!You're a star, Rocky!Thanks a million!JoseEDIT: I tested it and it works great. Link to comment Share on other sites More sharing options...
babyewok Posted August 24, 2010 Share Posted August 24, 2010 How would you do this so it shows for only certain attribute groups (i.e. those that affect price)? Link to comment Share on other sites More sharing options...
dtbaker Posted September 1, 2010 Share Posted September 1, 2010 I've done this, it's a bit hard to explain because we've got a custom theme, but below is the php code and template code to get the "from" thing working. Quite a bit of code because it has to check if each attribute affects the price.In category.php this is what the code looked like "before": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); } and this is what it looks like "now": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); foreach($cat_products as &$cat_product){ $cat_product['all_prices'] = array(); $product = new Product($cat_product['id_product'], true, intval($cookie->id_lang)); $cat_product['all_prices'][] = floatval($cat_product['price']); $attributesGroups = $product->getAttributesGroups(intval($cookie->id_lang)); if (Db::getInstance()->numRows()) { $combinationImages = $product->getCombinationImages(intval($cookie->id_lang)); foreach ($attributesGroups AS $k => $row){ $cat_product['all_prices'][] = floatval($cat_product['price']) + floatval($row['price']); } } $diff_prices = array_unique($cat_product['all_prices']); array_multisort($diff_prices); $cat_product['from_price'] = (count($diff_prices)>1) ? array_shift($diff_prices) : false; } } Then in themes/your_theme/product-list.tpl this is what it might have looked like before: {convertPrice price=$product.price} and this is what i changed it to. {if $product.from_price}from {convertPrice price=$product.from_price}{else}{convertPrice price=$product.price}{/if} Examples:http://bastbodyjewellery.com.au/7-eyebrow-jewelleryhttp://bastapparel.com.au/18-punk-accessories Link to comment Share on other sites More sharing options...
babyewok Posted September 9, 2010 Share Posted September 9, 2010 Hmm, that doesn't seem to work at all for me Link to comment Share on other sites More sharing options...
popo559 Posted October 7, 2010 Share Posted October 7, 2010 I've done this, it's a bit hard to explain because we've got a custom theme, but below is the php code and template code to get the "from" thing working. Quite a bit of code because it has to check if each attribute affects the price.In category.php this is what the code looked like "before": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); } and this is what it looks like "now": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); foreach($cat_products as &$cat_product){ $cat_product['all_prices'] = array(); $product = new Product($cat_product['id_product'], true, intval($cookie->id_lang)); $cat_product['all_prices'][] = floatval($cat_product['price']); $attributesGroups = $product->getAttributesGroups(intval($cookie->id_lang)); if (Db::getInstance()->numRows()) { $combinationImages = $product->getCombinationImages(intval($cookie->id_lang)); foreach ($attributesGroups AS $k => $row){ $cat_product['all_prices'][] = floatval($cat_product['price']) + floatval($row['price']); } } $diff_prices = array_unique($cat_product['all_prices']); array_multisort($diff_prices); $cat_product['from_price'] = (count($diff_prices)>1) ? array_shift($diff_prices) : false; } } Then in themes/your_theme/product-list.tpl this is what it might have looked like before: {convertPrice price=$product.price} and this is what i changed it to. {if $product.from_price}from {convertPrice price=$product.from_price}{else}{convertPrice price=$product.price}{/if} Examples:http://bastbodyjewellery.com.au/7-eyebrow-jewelleryhttp://bastapparel.com.au/18-punk-accessories So nice, it works on my shop Link to comment Share on other sites More sharing options...
popo559 Posted October 7, 2010 Share Posted October 7, 2010 if you think about some product with 'quantity discount', it will be more better Link to comment Share on other sites More sharing options...
ukbaz Posted November 23, 2010 Share Posted November 23, 2010 Hi Rocky I'm using 1.3.2.3 final and the prodcut-list.tpl code is once again different. >{if isset($products)} <!-- Products list --> </pre> <ul> {foreach from=$products item=product name=products} getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" width="{$homeSize.width}" height="{$homeSize.height}" /> {if $product.new == 1}{l s='new'}{/if}{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'} {$product.description|truncate:360:'...'|strip_tags:'UTF-8'} {$product.reference} {if $product.on_sale} {l s='On sale!'} {elseif ($product.reduction_price != 0 || $product.reduction_percent != 0) && ($product.reduction_from == $product.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $product.reduction_to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $product.reduction_from))} {l s='Price lowered!'} {/if} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} {l s='ex VAT'} {if ($product.quantity > 0)}{l s='Available'}{else}{l s='Out of stock'}{/if} {if ($product.allow_oosp OR $product.quantity > 0) && $product.customizable != 2} {l s='Add to cart'} {else} {l s='Add to cart'} {/if} {l s='View'} {/foreach} </ul> <br> <!-- /Products list --><br Any idea what change I'd need to make to get the 'from' to show only on items with attributes?ThanksBaz Link to comment Share on other sites More sharing options...
babyewok Posted April 26, 2011 Share Posted April 26, 2011 dtbaker would you be able to explain further as I can't seem to get your solution working for me? Link to comment Share on other sites More sharing options...
babyewok Posted April 26, 2011 Share Posted April 26, 2011 OK, well failing getting the 'from' to automatically appear for products with attributes with price impacts, how about getting it to show when one particular attribute group is assigned to the product? Link to comment Share on other sites More sharing options...
thehandlestudio Posted July 9, 2011 Share Posted July 9, 2011 Does anyone know how to get this working for 1.4.3.0?Regards,Mark. Link to comment Share on other sites More sharing options...
soigroeg Posted August 16, 2013 Share Posted August 16, 2013 I would like to know it too. There doesn't seem to be a category.php in 1.5.4.2 like the one above. Can someone explain dtbakers code? Link to comment Share on other sites More sharing options...
jager Posted January 24, 2014 Share Posted January 24, 2014 You'll need to edit change line 18 of product-list.tpl in your theme's directory (in PrestaShop v1.3) from: <span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span> to: <span class="price" style="display: inline;">{l s='from'} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span> Ok, now I can show "From" before price... but can I display the lowest price if I have a quantity discount? PS version 1.4.11 Link to comment Share on other sites More sharing options...
anson.c Posted January 24, 2014 Share Posted January 24, 2014 Nice! How about if I want to display the "from" in different languages? Link to comment Share on other sites More sharing options...
Essex Dog Supplies Posted February 13, 2014 Share Posted February 13, 2014 (edited) On my site I need to display 'From £' prices for products that have multiple options that change the price only. For example, a bag of 2kg dog food is £5.99 which is the cheapest, then a 10kg bag is £13.99. If I have products that come in a different colour but not there is no change to the price, I don't need it to display a 'From £' price. I hope this makes sense and hopefully someone can give me a solution that works. Cheers. I'm using PS v1.4.9 Edited February 13, 2014 by Essex Dog Supplies (see edit history) 1 Link to comment Share on other sites More sharing options...
cc10 Posted April 1, 2014 Share Posted April 1, 2014 On my site I need to display 'From £' prices for products that have multiple options that change the price only. For example, a bag of 2kg dog food is £5.99 which is the cheapest, then a 10kg bag is £13.99. If I have products that come in a different colour but not there is no change to the price, I don't need it to display a 'From £' price. I hope this makes sense and hopefully someone can give me a solution that works. Cheers. I'm using PS v1.4.9 Also want this on my 1.4.9 prestashop site, from price is a must you would of thought. Link to comment Share on other sites More sharing options...
oracle178 Posted April 14, 2014 Share Posted April 14, 2014 On my site I need to display 'From £' prices for products that have multiple options that change the price only. For example, a bag of 2kg dog food is £5.99 which is the cheapest, then a 10kg bag is £13.99. If I have products that come in a different colour but not there is no change to the price, I don't need it to display a 'From £' price. I hope this makes sense and hopefully someone can give me a solution that works. Cheers. I'm using PS v1.4.9 maybe someone has a solution for PS v1.5.x, really need to display "from" before product price in products list, where not only are the combinations, but their prices are different. If product has several combinations, but their prices are the same, do not to display "from". Thanks Link to comment Share on other sites More sharing options...
leozao Posted April 16, 2015 Share Posted April 16, 2015 Hi all, Does anybody knows how this could be done in 1.6.0.14? Thank you! Link to comment Share on other sites More sharing options...
Krasnyinterier.sk Posted May 7, 2017 Share Posted May 7, 2017 You are right. In that case, try: <span class="price" style="display: inline;">{if $product.id_product_attribute}{l s='from'}{/if} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span> I haven't tested it, but I think it should work. Hi everyone, that code works well, but does enybody know, how to change scope from {if $product.id_product_attribute} {l s='from'} {/if} // which displays "from" to all products with any attributes to display "from" only for a product with a specific, for ex. my id_feature_value == 4258 ? I tried some codes but none "from"displayed {if $product.id_feature_value == 4258} {l s='from'} {/if} 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