I'm trying to calculate the price difference between old price and new price, and if the price has dropped to display by how much, both Nominally and in Percent.
So, basically these are 2 simple formulas that should look like this:
NOMINAL PRICE DROP = field_price_original - field_price_new
PERCENTAGE PRICE DROP = ( (field_price_new - field_price_original) / field_price_original ) * 100
I tried setting this up through Rules (unsuccessfully), but it seems that doing it through Computed Field will not be so heavy on the server. Using Computing Field I have the following formula:
$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_price_original'))) - array_pop(array_pop(field_get_items($entity_type, $entity, 'field_price_new')));
The number is set as float, 10.2. But for some reason it doesn't work.
Can someone please help and provide the correct syntax for Computed Field?