1

I copy these file from core to local folder from app/code/core/Mage/SalesRule/Model/Quote/Discount.php.

**WHAT I NEED TO DO IS ROUND OFF DISCOUNT VALUE WHICH ALSO ROUND OFF TOTAL VALUE AS WELL **

enter image description here

I used round function :

 public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
        $amount = round($address->getDiscountAmount()); /* round up value */

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

2 Answers 2

1

Magento pass discount value as negative value in calculating function,

E.g

Subtotal = Rs. 100

Shipping = Rs. 20

Discount = Rs. 20

Then,
Grand Total = Rs. 100

Here,

Magento calculate the discount amount (-20) so, Function just add all the values with (+) sign.

Like , 100 + 20 + (-20) = 100

6
  • how could i correct grand total with round off value Jan 5, 2017 at 9:21
  • You can do like this , $this->_addAmount(-round($item->getDiscountAmount())); Jan 5, 2017 at 9:44
  • not working it's show total 0.0 and no label show Jan 5, 2017 at 11:55
  • Please add your code so can figure out the problem. Jan 6, 2017 at 5:08
  • I solved it by same code mention above put some code overwrite it so find out , Normally this code work fine.. Jan 24, 2017 at 9:11
0
 public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
        $amount = round($address->getDiscountAmount()); /* round up value */

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

I solved by above code..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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