Donnerberg Posted December 29, 2016 Share Posted December 29, 2016 Hello, I have inserted : {if $product->id == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if} in the product.tpl file. And code WORKS great. After that, I have tried to put the same code in the product-list.tpl file, but if statemant does not work.( without {if} statemant, text shows on every product on the homepage ) Code is: <div class="right-block"> <h5 itemprop="name"> {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url" > <span class="list-name">{$product.name|truncate:60:'...'|escape:'html':'UTF-8'}</span> <span class="grid-name">{$product.name|truncate:30:'...'|escape:'html':'UTF-8'}</span> </a> <div>{if $product->id == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if}</div> </h5> Why code works in product.tpl file, and it dont work in product-list.tpl? Does any1 have clue, how to put {if} statemant and to show text under product image ONLY for product with ID 12 Thank you ALOT, Nikola Link to comment Share on other sites More sharing options...
metal1616 Posted December 29, 2016 Share Posted December 29, 2016 (edited) Hi! In product-list.tpl, the variable wich refers to the products, works differently. You need to change tha call to the product ID to this: $product.id The code in product-list.tpl should be like this: <h5 itemprop="name"> {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url" > <span class="list-name">{$product.name|truncate:60:'...'|escape:'html':'UTF-8'}</span> <span class="grid-name">{$product.name|truncate:30:'...'|escape:'html':'UTF-8'}</span> </a> <div>{if $product.id == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if}</div> </h5> I think that this is the problem. Edited December 29, 2016 by metal1616 (see edit history) Link to comment Share on other sites More sharing options...
razaro Posted December 29, 2016 Share Posted December 29, 2016 Try with <div class="right-block"> <h5 itemprop="name"> {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url" > <span class="list-name">{$product.name|truncate:60:'...'|escape:'html':'UTF-8'}</span> <span class="grid-name">{$product.name|truncate:30:'...'|escape:'html':'UTF-8'}</span> </a> {if $product.id == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if} {/if} </h5> Note in product.tpl variable $product is Object so you use ->. In product list is Array so you access properies with . Also this is not good way, to hard code it like that. Try to use Availabily settings http://doc.prestashop.com/display/PS16/Managing+Products#ManagingProducts-AvailabilitySettings 1 Link to comment Share on other sites More sharing options...
Donnerberg Posted December 29, 2016 Author Share Posted December 29, 2016 Thank you for fast answer, But code does not work ( Whole site can't to be loaded ) So I need some other solution. I need to show simple text under exacly one product. It should be way to do this simply... Link to comment Share on other sites More sharing options...
razaro Posted December 29, 2016 Share Posted December 29, 2016 Sorry was not paying attention, $product.id_product need to be used {if $product.id_product == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if} 1 Link to comment Share on other sites More sharing options...
Donnerberg Posted December 30, 2016 Author Share Posted December 30, 2016 Sorry was not paying attention, $product.id_product need to be used {if $product.id_product == 12} <p class="redtxt" style="padding:5px 0 0 0; font-size:15px;"><strong>Delivery in 24h</strong></p> {/if} Now it works like a charm, thank you 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