Jump to content

Show text only in products of two categories


seog

Recommended Posts

Hello friends

 

I need display in product.tpl Warranty text according category id. I want display "12 months" if product is in categories 14 and 15 and "24 months" for the rest of the products.

 

 

I tried with these codes but don´t work:

1. {if  $smarty.get.id_category==14 AND $smarty.get.id_category==15}12 MONTHS{else}24 MONTHS{/if}


2. {if  $smarty.get.id_category != 14 AND $smarty.get.id_category != 15}12 MONTH{else}24 MONTHS{/if}


3. {if $smarty.get.id_category == 14 or $smarty.get.id_product == 15}12 MONTHS{else}24 MONTHS{/if}


4. {if in_array(14,Product::getProductCategories($product->id|intval))}12 MONTHS{else}24 MONTHS{/if}


5. {assign findcat [['id_category' == 14], ['id_category' == 15]]}
{if Product::idIsOnCategoryId($product.id_product, $findcat)}
    12 MONTHS{else}24 MONTHS
{/if}
 
 
Some contribution please?
 
best regards
Link to comment
Share on other sites

OK it work i tested the code.

 

So if you wanna deal with

 

current categorie use : {if $id_category_current != 14 AND $id_category_current != 15}12 MONTH{else}24 MONTHS{/if}

 

 categorie parent use : {if $id_category_parentt != 14 AND $id_category_parent != 15}12 MONTH{else}24 MONTHS{/if}

Edited by Mohamadou Ndiaye (see edit history)
  • Like 1
Link to comment
Share on other sites

current categorie use : {if $id_category_current != 14 AND $id_category_current != 15}12 MONTH{else}24 MONTHS{/if}

Working in reverse, category 14 and 15 display 24 MONTH and the rest displaying 12 MONTH

 

 

 

Try this

{if $category->id == 14 || $category->id == 15 }
 
12 Months Warranty


{else}

 24 Months Warranty
	

{/if}

 

WORKING PERFECT !!!!

 

Thank you very much for all your contributions!!!

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