ancawonka is suggesting that get_price_html()
is returning something that cannot be compared to 200
, which is quite likely since it is returning an HTML string and you are trying to compare it to an integer. As suggested, echo out the returned string and decide how to extract just a price value without other HTML, nor currency signs, nor thousands separators, but keep the decimal point. preg_match()
might work for this.
Besides a type mismatch, the code you tried has a few syntax errors. It may be the forum’s parser corrupted your code because you didn’t put your code between backticks. Here is a better version, though the type mismatch issue remains:
<div id = "foo" <?php $price = $product->get_price_html(); if ( 200 > $price ) { echo 'style = "display: none;"'; } ?> >
text
</div>
Spaces in some places is a stylistic choice, but in other places it causes a parsing error. Same for upper/lower case, sometimes a stylistic choice, other times it makes a difference. With time you’ll learn where it matters and where it doesn’t.