-1

I didn't see an answer in a quick search, so I decided make a new one, I am on the checkout_shipping.php in OScommerce 2.3.4 and I am adding an if statement so that the value of $0.00 is the text "free" here is my code, it is incomplete because it is crashing the page, here is the code that I modified.

<?php
if ('cost' > 0) {
?>
<td><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'],       
(isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td>
<php
} ?>

fixed, it was syntax error; also cost wasn't a value, so I changed it to $i

Ryan Blevins
  • 166
  • 1
  • 9

2 Answers2

2

Actually you are comparing 0 to a string, what you need to do is compare zero to a variable like so:

<?php

$count = 1;
if($count > 0) {
    //Do your logic here
}
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Bioto
  • 1,127
  • 8
  • 21
1

The first issue is your use of <php instead of <?php. But also the syntax of if ('cost' > 0) { makes no sense at all. So assuming cost is actually a variable named $cost, then this should work:

if ($cost > 0) {
?>
<td><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'],       
(isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></td>
<?php
} ?>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103