I'm trying to create a conditional field that checks to see if list-price is greater than sell-price or list-price is equal to $0.00. I would like to use this with views; hide the list-price field if the above is true. How can I achieve this? Thanks.

Comments

fehin’s picture

I received an email about this today so I'm posting my solution for anyone looking for something similar.

I created a cck field called "sales_list_price" and used "computed" widget and I used the code below. Then in my views, I used this field instead of Ubercart list price field.

Computed Code: ---- This is saying if Ubercart List price is greater than Sell price and if List price is greater than $0 then show the value of list price. Otherwise don't show anything.

if ($node->list_price > $node->sell_price && $node->list_price > '0.00'){
$node_field[0]['value']= $node->list_price;
}
else{
 $node_field[0]['value']='';}

Display Format: ------ This is saying if the value is greater than 0, display the value and with a $ sign in front.

if ($node_field_item['value'] > '0.00') {
$display = t('$') . $node_field_item['value'];}
fehin’s picture

Status: Active » Closed (fixed)