So I have an entity called "Discount" with the following fields:
field_discount_percentageis an integer field.
field_discount_priceis a commerce price field.
I can test whether the percentage field contains a value to avoid exceptions via:
However this does not work for commerce price fields, as
$discount_wrapper->field_discount_price is an object in itself and so the following is always true:
Alternatively I tried:
However this produces an exception on zero values, and the following:
Which returns a PHP Fatal error as
empty() can only take variables and not functions.
I am now resorting to:
However this does not feel explicit and I was hoping there is a more conventional means to test price fields.