Jump to content

[SOLVED] Please help - Show specific icon if product is in category id


plauengco

Recommended Posts

Hello,

I want to show a "Glow in the Dark" button for any products belonging in my Glow in the Dark category when viewed in product-list.tpl.

I'm assuming it's very similar to how the "New" button is being displayed using the code:

{if $product.new == 1}{l s='new'}{/if}



Any ideas as far as doing something similar by displaying a button if a product belongs to a specific category?

Thank you.

-Paul

Link to comment
Share on other sites

Do you want all products on the "Glow in the Dark" category listings page to glow? You can change line 22 of product-list.tpl from:

{l s='Add to cart'}



to:

{l s='Add to cart'}



Change 2 to the ID of the "Glow in the Dark" category. This will add a "glow" class on the "Add to cart" buttons for that category, which you can use to style just those buttons.

Link to comment
Share on other sites

Hi rocky,
Thank you very much for the help. I really appreciate you taking the time to reply.

Basically I have a category called "glow in the dark". Certain products in this category also belong in other categories.

What I am trying to do is to add a "glow in the dark" icon to any product that is in "glow in the dark" (category id# 33), no matter which category it's being viewed in.

I have tried 3 of the following codes. The first one only adds the icon whenever I am viewing the glow in the dark category. The last two do no work.

{if $smarty.get.id_category == 33} 

{/if}

{if $product->id_category_default == 33} 

{/if}

{if $product->id_category == 33} 

{/if}



Any ideas rocky?

Thanks again!

Link to comment
Share on other sites

The only solution I can think of is to set the default category of each product to the "Glow in the Dark" category, then use the following code in product-list.tpl:

{if $product.id_category_default == 33}



That should work. When you go to a product through a category, that category will be displayed in the breadcrumb bar. The only problem is that if you go directly to a product or through another page, the "Glow in the Dark" category will be displayed in the breadcrumb bar.

Link to comment
Share on other sites

  • 2 weeks later...

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