Best way to test if a commerce price field has a value So I have an entity called "Discount" with the following fields:


field_discount_percentage is an integer field.
field_discount_price is a commerce price field.


I can test whether the percentage field contains a value to avoid exceptions via:

if (empty($discount_wrapper-&gt;field_discount_percentage))


However this does not work for commerce price fields, as $discount_wrapper-&gt;field_discount_price is an object in itself and so the following is always true:

if (empty($discount_wrapper-&gt;field_discount_price))


Alternatively I tried:

if (empty($discount_wrapper-&gt;field_discount_price-&gt;amount))


However this produces an exception on zero values, and the following:

if (empty($discount_wrapper-&gt;field_discount_price-&gt;value()))


Which returns a PHP Fatal error as empty() can only take variables and not functions.

I am now resorting to:

if ($discount_wrapper-&gt;field_discount_price-&gt;value())


However this does not feel explicit and I was hoping there is a more conventional means to test price fields.
Adding isset() to that last if statement is a bit more explicit. 

if (isset($discount_wrapper-&gt;field_discount_price-&gt;value()))