Reputation: 5
{{
if( sfprice_administrator_applicable() && sfprice_get_administrator_price($product) > 0 )
$price = sfprice_get_administrator_price($product);
return $price;
}
{ elseif( sfprice_resellerplus_applicable() && sfprice_get_resellerplus_price($product) > 0 )
$price = sfprice_get_resellerplus_price($product);
return $price;
}
{ elseif( sfprice_reseller_applicable() && sfprice_get_reseller_price($product) > 0 )
$price = sfprice_get_reseller_price($product);
return $price;
}
{ elseif( sfprice_corporateplus_applicable() && sfprice_get_corporateplus_price($product) > 0 )
$price = sfprice_get_corporateplus_price($product);
return $price;
}
{ elseif( sfprice_corporate_applicable() && sfprice_get_corporate_price($product) > 0 )
$price = sfprice_get_corporate_price($product);
return $price;
}
{ else( sfprice_smallbusiness_applicable() && sfprice_get_smallbusiness_price($product) > 0 )
$price = sfprice_get_smallbusiness_price($product);
return $price;
}}
I am sure that this is very wrong but i am extremely new to programming so i would appreciate direction on how this should have been coded?
I understand my issue is with the if/elseif/else statement structure. But i am unsure how to properly format the information.
Upvotes: 0
Views: 41
Reputation: 26450
Your problem is how you bracket your if
-statements. How they are bracketed and formatted below is how it should look.
Use this code instead
if (sfprice_administrator_applicable() && sfprice_get_administrator_price($product) > 0 ) {
$price = sfprice_get_administrator_price($product);
return $price;
} elseif (sfprice_resellerplus_applicable() && sfprice_get_resellerplus_price($product) > 0 ) {
$price = sfprice_get_resellerplus_price($product);
return $price;
} elseif (sfprice_reseller_applicable() && sfprice_get_reseller_price($product) > 0 ) {
$price = sfprice_get_reseller_price($product);
return $price;
} elseif (sfprice_corporateplus_applicable() && sfprice_get_corporateplus_price($product) > 0 ) {
$price = sfprice_get_corporateplus_price($product);
return $price;
} elseif (sfprice_corporate_applicable() && sfprice_get_corporate_price($product) > 0 ) {
$price = sfprice_get_corporate_price($product);
return $price;
} else (sfprice_smallbusiness_applicable() && sfprice_get_smallbusiness_price($product) > 0 ) {
$price = sfprice_get_smallbusiness_price($product);
return $price;
}
Note that PHP runs in a way that selects the first elseif
that returns true.
Upvotes: 1