VirtuoSEO Posted August 16, 2010 Share Posted August 16, 2010 Hi everyone,Can anyone point me in the right direction?I need a little bit of code to check if a product has more than one attribute and if it does I want to add the text "From" before the price in product-list.tpl.Any ideas?Thanks! Link to comment Share on other sites More sharing options...
rocky Posted August 16, 2010 Share Posted August 16, 2010 Change line 18 of product-list.tpl in your theme's directory from: {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} to: {if $product.id_product_attribute > 0}{l s='From'} {/if}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} Link to comment Share on other sites More sharing options...
VirtuoSEO Posted August 17, 2010 Author Share Posted August 17, 2010 Hi Rocky, thanks for the reply. I needed to modify it to check for more than one attribute as all my products have a single attribute.Unfortunately this code shows From on all products. {if $product.id_product_attribute > 1}{l s='From'} {/if}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} Any idea what's wrong with it?Thanks again!EDIT: If it helps my original price section looked like this: {displayWtPrice p=$product.price} Link to comment Share on other sites More sharing options...
rocky Posted August 18, 2010 Share Posted August 18, 2010 Unfortunately, that's not so easy. There is no variable on the product listing page that tells you how many attributes a product has. Link to comment Share on other sites More sharing options...
VirtuoSEO Posted August 18, 2010 Author Share Posted August 18, 2010 Ahhh right.How about if I create an array of items that DON'T have more than one attribute in product-list.php (there aren't that many) and check the product names against that list?Would that be possible? Link to comment Share on other sites More sharing options...
babyewok Posted August 25, 2010 Share Posted August 25, 2010 I am trying to use similar code to hide a particular div on the product page when there are less than 2 attributes. I have tried: {if $product.id_product_attribute < 2}style="display: none"{/if} But this doesn't work - it breaks the page. This code works on the product list page, but not on the product page Link to comment Share on other sites More sharing options...
babyewok Posted August 25, 2010 Share Posted August 25, 2010 Yey! figured it out - just needed to take off product. and change to $id_product_attribute Link to comment Share on other sites More sharing options...
babyewok Posted August 25, 2010 Share Posted August 25, 2010 Ok so with a bit of tweeking I can now hide the div when there is one attribute and the colour picker is present (I hide my colour attributes and just use the picker so essentially, I just wnat to hide the div when colour is the only attribute) {if $id_product_attribute == 1 && $colors}style="display: none"{/if} Link to comment Share on other sites More sharing options...
babyewok Posted August 25, 2010 Share Posted August 25, 2010 Hmm, I take that back. ==1 doesn't work. <=1 or <2 hides the div regardless of the number of attributes....so close yet so far! Anyone have any ideas as to the missing link?? Link to comment Share on other sites More sharing options...
rocky Posted August 25, 2010 Share Posted August 25, 2010 I lost track of this thread while the email notifications weren't working. The $id_product_attribute variable contains the ID of the default combination. It doesn't contain how many attributes a product has. There is no variable with that information.VirtuoSEO's idea to maintain an array of products that should or shouldn't have "From" (depending on which array would be smaller) would work. For example, in category.php, search.php, new-products.php and best-sales.php: $from = array('1', '2', '3', '4'); $smarty->assign('from', $from); Then in product-list.tpl: {foreach from=$from item=$id_product}{if $product.id_product == $id_product}{l s='From'} {/if}{/foreach} Link to comment Share on other sites More sharing options...
babyewok Posted August 26, 2010 Share Posted August 26, 2010 Hi rocky. I kind of went off in another direction with this code. I was trying to use the code you gave before to hide a particular div on the product page when there are less than 2 attributes. I have tried: nearly works, but <=1 or <2 hides the div regardless of the number of attributes (and ==1 doesn't work at all)Any ideas onhow I can get this working? Link to comment Share on other sites More sharing options...
rocky Posted August 26, 2010 Share Posted August 26, 2010 Try the following: Link to comment Share on other sites More sharing options...
babyewok Posted August 26, 2010 Share Posted August 26, 2010 Perfect! I knew I could rely on you rocky - you're an invaluable asset to the prestashop forums! Link to comment Share on other sites More sharing options...
babyewok Posted August 26, 2010 Share Posted August 26, 2010 I had to make a change to allow for the text filed customisation when there were no groups at all. This seems to work: customizable==false}style="display: none"{/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