PrabuSS Posted May 23, 2017 Share Posted May 23, 2017 (edited) Hi I would like to show some text on my product listing page if feature value is 0 or empty. So here is my code in product-list.tpl file. {foreach from=$product.features item=feature} {if $feature.id_feature == 2}{if $feature.value == '0' OR empty($feature.value)} <p>test</p> {/foreach} {/if}{/if} But its not working. Please any one. PS Version : 1.6.1.11 Edited May 23, 2017 by PrabuSS (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted May 24, 2017 Share Posted May 24, 2017 (edited) Well, when I use your code it is working but I changed something, I removed ' ' arround 0 and I changed if's closing. If your value will be string then use '' around value. Try now and You can use another conditions if You want but in foreach loop. {foreach from=$product.features item=feature} {if $feature.id_feature == 2} {if $feature.value == 0 OR empty($feature.value)} <p>test</p> {/if} {/if} {/foreach} Edited May 24, 2017 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
PrabuSS Posted May 26, 2017 Author Share Posted May 26, 2017 Well, when I use your code it is working but I changed something, I removed ' ' arround 0 and I changed if's closing. If your value will be string then use '' around value. Try now and You can use another conditions if You want but in foreach loop. {foreach from=$product.features item=feature} {if $feature.id_feature == 2} {if $feature.value == 0 OR empty($feature.value)} <p>test</p> {/if} {/if} {/foreach} Hi Tons of thanks for your reply. Its working good. Could you please help me for this another one clarification? I would like to Reload a current page(Product list or details) after adding product to cart. Like expect to reload current page before opening ajax cart pop up. How do i do this? Link to comment Share on other sites More sharing options...
hakeryk2 Posted May 26, 2017 Share Posted May 26, 2017 I would like to Reload a current page(Product list or details) after adding product to cart. Like expect to reload current page before opening ajax cart pop up. How do i do this? Uhmm this is kinda weird logic and I don't know what You want to achieve with this but I will not tell You how to do this because I simply don't know You should post a new topic with exact clarification what You want to achieve and how. You can close this topic by clicking "Mark as Solved next to my post in bottom right section. Link to comment Share on other sites More sharing options...
PrabuSS Posted May 26, 2017 Author Share Posted May 26, 2017 Uhmm this is kinda weird logic and I don't know what You want to achieve with this but I will not tell You how to do this because I simply don't know You should post a new topic with exact clarification what You want to achieve and how. You can close this topic by clicking "Mark as Solved next to my post in bottom right section. I've already created new topic. Please see this one https://www.prestashop.com/forums/topic/610409-would-like-to-change-add-to-cart-background-color-after-clickor-after-adding-product-to-cart/ Link to comment Share on other sites More sharing options...
PrabuSS Posted May 26, 2017 Author Share Posted May 26, 2017 (edited) Well, when I use your code it is working but I changed something, I removed ' ' arround 0 and I changed if's closing. If your value will be string then use '' around value. Try now and You can use another conditions if You want but in foreach loop. {foreach from=$product.features item=feature} {if $feature.id_feature == 2} {if $feature.value == 0 OR empty($feature.value)} <p>test</p> {/if} {/if} {/foreach} Hi Tons of thanks for your reply. Its working good. Could you please help me for this another one clarification? I would like to Reload a current page(Product list or details) after adding product to cart. Like expect to reload current page before opening ajax cart pop up. How do i do this? Hi Unfortunately your code is not working on product details page I've tried like this <td> {foreach from=$features item=feature} {if $feature.id_feature == 3} {if $feature.value !== 0 OR !empty($feature.value)} {$feature.value|escape:'html':'UTF-8'}{/if}{/if} {if $feature.id_feature == 16} {if $feature.value !== 0 OR !empty($feature.value)} <span> + </span>{$feature.value|escape:'html':'UTF-8'}{/if}{/if} {/foreach}</td> If second value is empty it still shows + sign Edited May 26, 2017 by PrabuSS (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted May 29, 2017 Share Posted May 29, 2017 (edited) Hi Unfortunately your code is not working on product details page I've tried like this <td> {foreach from=$features item=feature} {if $feature.id_feature == 3} {if $feature.value !== 0 OR !empty($feature.value)} {$feature.value|escape:'html':'UTF-8'}{/if}{/if} {if $feature.id_feature == 16} {if $feature.value !== 0 OR !empty($feature.value)} <span> + </span>{$feature.value|escape:'html':'UTF-8'}{/if}{/if} {/foreach}</td> If second value is empty it still shows + sign But you use !empty in your code which means if NOT EMPTY - remove. In previous code You didnt use negative sign. But if You want negative You have to use != instead of !== Edited May 29, 2017 by hakeryk2 (see edit history) 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