Calculation of two different numbers

Good afternoon, I wonder if someone can help me with a cal question. I currently have a drop down with the raw values of 1 - 4 inclusive. My calc element works out the cost based on the number selected

$tenCalc = (int)'{fees___Number_Of_Tenants_raw}' * 175; return '?'.$tenCalc;

The 175 is the cost but if the number is 2 or more the cost is ?150 so for example

1 tenant = ?175

2 tenants = ?175 + ?150 = ?325

So what I need to do is calculate the total of the number of tenants if 2 or more. i am guessing it should be

if 1 tenant=total else 2+ tenants =total

Link for info

Hope that makes sense

Thanks

Mark
 
$noTen = (int)'{fees___Number_Of_Tenants_raw}';
$tenCalc = 175 + 150 * ($noTen - 1);
 
It's not returning anything because, well, there is no return. I think Troester assumed you would add the same return statement you have in your original.

--hugh
 
Thanks Hugh

This is what I have now but it is still not working so I have clearly got it wrong :)

$noTen = (int) '{fees___Number_Of_Tenants_raw}';
$tenCalc = 175 + 150 *; ($noTen - 1); return '?'.$tenCalc;

Any help would be appreciated

Thanks

Mark
 
This code is assuming $noTen >=1, seems you have 0.
So
if ($noTen>0) {
$tenCalc = 175 + 150 * ($noTen - 1);
return '?'.$tenCalc;
}
else {
//whatever you want to return in case of 0
}
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top