hakeryk2 Posted March 24, 2016 Share Posted March 24, 2016 (edited) 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 March 25, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
yaniv14 Posted March 24, 2016 Share Posted March 24, 2016 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} Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 24, 2016 Author Share Posted March 24, 2016 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 More sharing options...
yaniv14 Posted March 24, 2016 Share Posted March 24, 2016 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 More sharing options...
musicmaster Posted March 25, 2016 Share Posted March 25, 2016 Did you try {if $product.id_category_default == 16} too? Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 25, 2016 Author Share Posted March 25, 2016 Guys thank Your for your replies. Code from @ndiaga is working but I used somehting like this because it is much more useful {if in_array(13,Product::getProductCategories($product->id|intval))} my code {/if} 1 1 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