I am trying to show text on a product page, when the price is above 300. I am using the following code:
{if $product.integerprice >= 300} Free shipping {/if}
$product.integerprice is the price.
It works, but only up to 1.000 (which is 1000, but the price is generated with a dot for thousands). After 1.000, it stops showing the text.
I haven't got any luck figuring the problem, hope someone can guide me.
If the dot is the problem, then just get rid of it:
{if str_replace('.', '', $product.integerprice) >= 1000} Free shipping {/if}
So why does 300 work then? In your case you are comparing a string to a number. PHP automatically converts your string to a number in that case. So you have:
'300' >= 300 //true
, string converted to 300
'1.000' >= 1000 //false
, string converted to 1, since PHP thinks it's a float.
due to question update – I'm not strong in smarty. But I guess you can do the same (remove dot) with replace.