[SOLVED] Products, smarty if value
Posted: Thu Apr 10, 2014 10:21 am
I have a little smarty trouble here, as a non programmer.
I have an extra field for the products, which when activated means the product is not available anymore (vergriffen) and therefore the "add to cart" button is not displayed on that product. The code in the products list template is s follows:
{if $entry->fields.vergriffen == true}
vergriffen
{else}
{Cart2 sku=$entry->sku} <div class="preis">CHF {$entry->price|number_format:2}</div>
{/if}
In my understanding this will show the text "vergriffen" if the field value is = true. And in all other cases it shows the button
And it works so far. BUT, only if there is no other value present. There have been cases where once the field has been activated and deactivated and the database ends up containing "false" for this product. Strange that in that case it also displays "vergriffen", but it must show the "add to cart" button.
Only if I delete the entry in the database, it works properly again. Not even leaving it blank works.
So what did I wrong in the smarty code? I mean, if its not "true" but in any other case (blank, false, dummydumb or whatever) the "else" statement should take effect. Or not?
Thanks for any enlightment on the matter.
Thom
I have an extra field for the products, which when activated means the product is not available anymore (vergriffen) and therefore the "add to cart" button is not displayed on that product. The code in the products list template is s follows:
{if $entry->fields.vergriffen == true}
vergriffen
{else}
{Cart2 sku=$entry->sku} <div class="preis">CHF {$entry->price|number_format:2}</div>
{/if}
In my understanding this will show the text "vergriffen" if the field value is = true. And in all other cases it shows the button
And it works so far. BUT, only if there is no other value present. There have been cases where once the field has been activated and deactivated and the database ends up containing "false" for this product. Strange that in that case it also displays "vergriffen", but it must show the "add to cart" button.
Only if I delete the entry in the database, it works properly again. Not even leaving it blank works.
So what did I wrong in the smarty code? I mean, if its not "true" but in any other case (blank, false, dummydumb or whatever) the "else" statement should take effect. Or not?
Thanks for any enlightment on the matter.
Thom