Jump to content

[Solved] If product is in category then do something


hakeryk2

Recommended Posts

Hello community,

 

I am strugling with some problem because on product page I want to show something only when this product is from specific category but I can't do it. Is there any simple method to get this work in product.tpl?

 

Any help will be appreciated 

Edited by hakeryk2 (see edit history)
Link to comment
Share on other sites

When you say specific category do you mean that the product is assigned to that category as default category?

If yes, than you can use: {$product->id_category_default}

 

I used 

{if $product->id_category_default == 16}
				my code here
			{/if}

and it is not working. I tested it on product which is in category with id 16 (which is default as well).

Link to comment
Share on other sites

Make sure that your if statement is not inside another if statement.

Also try to do $product->id_category_default|intval just in case because you compare it to integer.

Try to print $product to see what you get as default category {$product|@print_r}

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