How To Check Product Category With Smarty

Hi All,

I want to some additional information in product page when some product in certain category out off stock.

For example : if the product in Category "A", I want to change the information of out off stock become "Estimated delivery 1 month".

I think to update in file product_data.tpl, line :

{if $product.tracking == "ProductTracking::TRACK_WITH_OPTIONS"|enum}
{assign var="out_of_stock_text" value=__("text_combination_out_of_stock")}
{else}
{assign var="out_of_stock_text" value=__("text_out_of_stock")}
{/if}

But I dont know the code in smarty how to check if product in category "A"?

Sorry I'm new with smarty, someone can help very appreciate!

Regards,

Try this code:

{if $product.main_category == 123}
     Estimated delivery 1 month
{/if}

where 123 - is the ID of the category (can be found in the admin panel)

Many thanks, work well!

Try this code:

{if $product.main_category == 123}
     Estimated delivery 1 month
{/if}

where 123 - is the ID of the category (can be found in the admin panel)

How if I have sub category? this code only work in 1 level category. Thanks

How if I have sub category? this code only work in 1 level category. Thanks

It is required to make additional requests to database to get parents of the main product category.

Oh, oke. Thanks for your information.