1

In cart page we can see the discount row only if a customer add a coupon code(?). What I want to do is adding the discount as zero for every cart page even there is not any coupon code applied.

What I see:

Total (Inc VAT) £42.00

Subtotal (net) £35.00

Subtotal (Inc VAT) £42.00

VAT £7.00

What I want:

Discount £0.00

Total (Inc VAT) £42.00

Subtotal (net) £35.00

Subtotal (Inc VAT) £42.00

VAT £7.00

This is my design/.../template/checkout/total/default.phtml file for viewing discount with coupon code:

<tr>
<td 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; ?>
</td>
<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 I'm having is whenever cart page is loaded, this block won't load, unless there is coupon code applied, obviously. What I want to know is that is there any flag or controller for make the block appear even no coupon is applied so in above block I can check whether coupon is applied or not to customize the above view. Can you give me any suggestions?

PS: here coupons means shopping cart price rules.

2

In the class Mage_SalesRule_Model_Quote_Discount there is this method that adds the discount total to the list of totals:

public function fetch(Mage_Sales_Model_Quote_Address $address)
{
    $amount = $address->getDiscountAmount();

    if ($amount!=0) {
        $description = $address->getDiscountDescription();
        if (strlen($description)) {
            $title = Mage::helper('sales')->__('Discount (%s)', $description);
        } else {
            $title = Mage::helper('sales')->__('Discount');
        }
        $address->addTotal(array(
            'code'  => $this->getCode(),
            'title' => $title,
            'value' => $amount
        ));
    }
    return $this;
}

You can see here that the total is added only when the discount amount is not zero if ($amount!=0) {.
So just rewrite this class and change the method I mentioned. Remove the if statement and it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.