how to check if a product is under a specific category. example: if {$product_is_in_catergory="electronics"} div hide{/if}
Check $product.category_ids array to check IDs of all additional categories
Check $product.category_ids array to check IDs of all additional categories
Please how can I implement this? like an example. Thanks
E.g.
{if 123|in_array:$product.category_ids} ... your code here... {/if}
where 123 - ID of required category
I tried it, it won't show "... your code here..." in products listed under the category id
Print out $product array and check if the category_ids array exists there
{$product|fn_print_r}
Thank you so much this solved my problem
The only problem is that it can't check the child category, only the parent category
The only problem is that it can't check the child category, only the parent category
Please clarify what do you mean
It only works when the product is listed on the parent category.
example: Cell phones > apple > iphone
using this snippet {if 123|in_array:$product.category_ids} ... your code here... {/if}, it doesn't show the text "... your code here..." on products listed in apple or iphone subcategories but will show on products listed directly under the parent category Cell phones.
I want if i use the parent category "cell phone" category id, it will also show in the products listed in the subcategories in side it.
In this case additional code modification is required. It is required to retrieve category path for each product category from database and use it in your condition
Please how can i do that? sounds easy from your explanation..
In this case additional code modification is required. It is required to retrieve category path for each product category from database and use it in your condition
Hire someone to perform this modification for you. It will not cost too high