Jump to content

Check product for attributes and display "From" text in product-list?


VirtuoSEO

Recommended Posts

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

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

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

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

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

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

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...