skip to Main Content

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

2

Answers


  1. 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
    }
    
    Login or Signup to reply.
  2. 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
    } ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search