tags:

views:

41

answers:

3

How can I wrap this entire statement below in a condition? So If the variable $uprice = 0 then I don't want to to display any of the code below

   <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item-  >getWeeeTaxAppliedAmount()): ?>

   <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>

  <?php else: ?>
  <?php echo $this->helper('checkout')->formatPrice($_item-    >getCalculationPrice()) ?>
  <?php endif; ?>
+3  A: 

This??

<?php if ($uprice === 0): ?>    
     <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item-  >getWeeeTaxAppliedAmount()): ?>    
     <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>    
     <?php else: ?>
     <?php echo $this->helper('checkout')->formatPrice($_item-    >getCalculationPrice()) ?>
     <?php endif; ?>
<?php endif; ?>
Sarfraz
+1 ...you rock! :P
zaf
@zaf: Thanks.................
Sarfraz
+1  A: 
phogl
+1  A: 

I think your code would be more readable by containing it all in one php block, and as Sarfraz said shouldn't it be as simple as adding a condition around the stuff?

<?php 
if ($uprice == 0)
{
    if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item-  >getWeeeTaxAppliedAmount())
    {
        echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition());
    }
    else 
    {
        echo $this->helper('checkout')->formatPrice($_item-    >getCalculationPrice());
    }
}
?>
Flash84x