Try merging it to one, if it won't work any other way :)
The problem will most likely be that it is not passed on properly from your PHP page to your TPL.
<p>
<i class="fa fa-chevron-down"></i>
<b>Lease To Buy Price:</b>
<span>
<?php
if($special > 0) {
$lease_price = (($special/1000)*38);
} else {
$lease_price = (($price/1000)*38); }
$lease_price = $this->currency->format($lease_price);
if($price > 500) {
echo $lease_price;
} else {
echo 'NA'; } ?></span>
</p>
In any normal cases you should check if
if(isset($lease_price)) {
// this gets executed if $lease_price has a value
} else {
// and this one if there is no initial value for $lease_price
}
You could handle this error with plenty of different approaches, but I think the key would be to ensure that your PHP code is in the right place, and referenced correctly in your template.
As there was a very similar post earlier on SO, I still think you should check the value of $price
by adding this to your template as a temporary error checking <?= $price ?>
since it might have already been converted to a string, and the if($price > 500)
will never get evaluated as '2,000.00' > 500
will not be true.
Update
$tempPrice = str_replace(',',"", $price); //gets rid of ","
$tempPrice = substr($tempPrice,1); //removes currency from the front
$tempPrice = floatval($tempPrice); //converts to double from string
and replace $price
with $tempPrice
in if
<p>
<i class="fa fa-chevron-down"></i>
<b>Lease To Buy Price:</b>
<span>
<?php
$tempPrice = str_replace(',',"", $price); //gets rid of ","
$tempPrice = substr($tempPrice,1); //removes currency from the front
$tempPrice = floatval($tempPrice); //converts to double from string
if($special > 0) {
$lease_price = (($special/1000)*38);
} else {
$lease_price = (($tempPrice/1000)*38); }
$lease_price = $this->currency->format($lease_price);
if($tempPrice > 500) {
echo $lease_price;
} else {
echo 'NA'; } ?></span>
</p>