如何在条件下包装下面的整个声明?所以如果变量$ 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; ?>
答案 0 :(得分:3)
此??
<?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; ?>
答案 1 :(得分:1)
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()) } }
答案 2 :(得分:1)
我认为你的代码在一个php块中包含所有代码会更具可读性,正如Sarfraz说的那样,它不应该像添加条件一样简单吗?
<?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());
}
}
?>