Echo Magento价格减去折扣

时间:2015-03-27 11:03:24

标签: magento echo

我试图在检查产品价格的基础上回应产品价格减去产品页面上的折扣。检查工作正常,但我无法输出折扣价。

  

示例:如果价格在50到100之间,我想echo product price * 0.8 (20% discount)

<?php if ($_product->getFinalPrice() >= 50 && $_product->getFinalPrice() < 100 )  : ?>
<?php echo $this->getPriceHtml($_product)*0.8 ?>
<?php endif; ?> 

我测试过规则正常。我还设法只输出价格。但是* 0.8不起作用(这可能不是计算它的正确方法,但我已经尝试了除了正确的东西之外的所有东西)

2 个答案:

答案 0 :(得分:2)

不,那不行。问题是你试图在html块上应用数学方程。

尝试使用此修改来表示修改价格,同时保持当前货币字符和小数规则;

<?php echo Mage::helper('core')->currency($_product->getFinalPrice()*.8, true, false); ?>

答案 1 :(得分:1)

嘿,你必须做那样的事情:

<?php if ($_product->getFinalPrice() >= 50 && $_product->getFinalPrice() < 100 )  : ?>
<?php 
      $valWithDiscount = $this->getPriceHtml($_product)*0.8;
      echo  $valWithDiscount;
?>
<?php endif; ?> 

那应该解决你的问题,让我知道。

Live Long and Prosper \ _ //