1
votes

I have a magento 1.7.0.2 install. I created a shopping price cart rule with coupon. Everything is fine except that the discount amount displayed in magento (cart, checkout,...) is an extremal value. I found out that extremal value is 2^64 (18 446 744 073 709 550 520). The configuration of the rule does not matter, the displayed discount is 2^64 always.

cart total example

The subtotal is fine, the shipping is fine the sum of these is 11669. after applying the discount(10%) on the subtotal(10961) the result is 9864. 9864+708=10573 is an acceptable result. So Everything is perfect except the displayed discount.

I don't know where does it go wrong. I can't find the related file. Please help.

Thanks a lot, István

1

1 Answers

2
votes

After all I found the solution. The cause of this error is simple. The discount amount stored by magento is signed, that means it has a negative sign. The file app/design/frontend/[yourfrontend]/[yourtheme]/template/checkout/total/default.phtml ( this is where the amount is written on screen) contains the following code:

<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>

The problem is the formatPrice() function, and the negative parameter. A simple solution is the abs() php function. Change the line

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

to

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

And here we go, the problem solved.

I hope that helps.