【问题标题】:Magento coupon shows extremal discountMagento 优惠券显示极端折扣
【发布时间】:2012-10-17 14:46:01
【问题描述】:

我安装了 magento 1.7.0.2。我使用优惠券创建了购物车价格规则。一切都很好,只是在 magento(购物车、结帐、...)中显示的折扣金额是一个极值。我发现极值是 2^64 (18 446 744 073 709 550 520)。规则的配置无关紧要,显示的折扣总是2^64。

小计很好,运费很好,这些总和是 11669。在小计 (10961) 上应用折扣 (10%) 后,结果是 9864。9864+708=10573 是可以接受的结果。所以除了显示的折扣外,一切都很完美。

我不知道哪里出错了。我找不到相关文件。请帮忙。

非常感谢, 伊斯特万

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    毕竟我找到了解决方案。这个错误的原因很简单。 magento 存储的折扣金额是有符号的,这意味着它有一个负号。文件 app/design/frontend/[yourfrontend]/[yourtheme]/template/checkout/total/default.phtml (这是金额在屏幕上写的地方)包含以下代码:

    <tr>
        <th colspan="<?php echo $this->getColspan(); ?>" style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
        <?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
            <?php echo $this->escapeHtml($this->getTotal()->getTitle()); ?>
        <?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
    </th>
    <td style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
        <?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
            <?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
        <?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
    </td>
    

    问题在于formatPrice() 函数和负参数。一个简单的解决方案是abs() php 函数。换行

    <?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
    

    <?php echo $this->helper('checkout')->formatPrice(abs($this->getTotal()->getValue())) ?>
    

    到这里,问题解决了。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 2014-07-26
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多