未显示在前端的变量问题

Here is the code I have:

in the php file:

if($special>0){
                            $lease_price = (($special/1000)*38);
                            } else {
                            $lease_price = (($price/1000)*38);
                            }
                            $lease_price = $this->currency->format($lease_price);

and in the front end tpl file:

                        <p>
                            <i class="fa fa-chevron-down"></i>
                            <b>Lease To Buy Price:</b>
                            <span><?php if($price>500){ ?>
              <?php echo $lease_price; ?>
              <?php } else { echo 'NA'; } ?></span>                     
                        </p>

Now I believe this works, but I think I'm entering the php code in the wrong area of the php document which is causing the variable $lease_price to not work.

Here's a link to a pastebin of my php file, where would I enter the code above? http://pastebin.com/bTPtvgUQ

Thanks for the help