I am displaying the "Price" or an item on the page, only if the field is not empty or if the item is not "sold".
<?php if(!empty(get_field('price')) && get_field('status') != 'Sold'): ?>
We now have a new status for Pending Payment items that we also want to hide the "price" of on the site. I have tried the below and some other variations but unable to get this to hide.
<?php if(!empty(get_field('price')) && get_field('status') != 'Sold' || 'Pending Payment' ): ?>
Thank you for your help.
I like to use in_array
for these kinds of things, especially because 2 items tends to grow to 3 or more eventually.
if (!empty(get_field('price')) && !in_array(get_field('status'), ['Sold', 'Pending Payment'])):
The empty
check isn't really needed, either, because string equality should fail anyways, too
if (!in_array(get_field('status'), ['Sold', 'Pending Payment'], true)):