seog Posted August 31, 2015 Share Posted August 31, 2015 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 More sharing options...
Mohamadou Ndiaye Posted August 31, 2015 Share Posted August 31, 2015 (edited) Hi in the product.tpl just use this: {if $product->id_category_default == 14} // Your code {else} {/if} Edited August 31, 2015 by Mohamadou Ndiaye (see edit history) Link to comment Share on other sites More sharing options...
Mohamadou Ndiaye Posted August 31, 2015 Share Posted August 31, 2015 (edited) ; Edited August 31, 2015 by Mohamadou Ndiaye (see edit history) Link to comment Share on other sites More sharing options...
seog Posted August 31, 2015 Author Share Posted August 31, 2015 Hello Thank you very much for your contribution. With this code I receive white page in product best regards Link to comment Share on other sites More sharing options...
Mohamadou Ndiaye Posted August 31, 2015 Share Posted August 31, 2015 (edited) sorry i just forgot one =. the right sintax is (==) {if $product->id_category_default == 14} // Your code {else} {/if} Edited August 31, 2015 by Mohamadou Ndiaye (see edit history) Link to comment Share on other sites More sharing options...
seog Posted August 31, 2015 Author Share Posted August 31, 2015 Thank you mr ambassador. I test this code but don´t work {if $product->id_category_default == 14}12 MONTHS{else}24 MONTHS{/if} Link to comment Share on other sites More sharing options...
Mohamadou Ndiaye Posted August 31, 2015 Share Posted August 31, 2015 What category do want to test , the current category,the default_category ,parent cateogrie or sub categories ? Link to comment Share on other sites More sharing options...
seog Posted August 31, 2015 Author Share Posted August 31, 2015 Hello Is parent category (no subcategorie), id category is 14 NOTE: My PS is 1.6.1.1 best regards Link to comment Share on other sites More sharing options...
Mohamadou Ndiaye Posted August 31, 2015 Share Posted August 31, 2015 (edited) 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 August 31, 2015 by Mohamadou Ndiaye (see edit history) 1 Link to comment Share on other sites More sharing options...
mickeyboy1 Posted August 31, 2015 Share Posted August 31, 2015 Try this {if $category->id == 14 || $category->id == 15 } 12 Months Warranty {else} 24 Months Warranty {/if} 1 Link to comment Share on other sites More sharing options...
seog Posted August 31, 2015 Author Share Posted August 31, 2015 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 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