4

enter image description here

How can I achieve round price value in Grand Total?

  • Thats weird, i can see 4 magento version tags.. which version you are using? – Lalit838 Jun 30 '17 at 7:38
  • it's mention above – Aks Jun 30 '17 at 8:01
  • Do you just need rounded price for grand total or for all the prices? – Lalit838 Jun 30 '17 at 8:26
  • For price conversion you can use this module this module Allows you to manage the price display in an easy way: to show a custom currency symbol, the number of decimals, the symbol's position, and so on. – Lalit838 Jun 30 '17 at 8:31
  • @Lalit838 - I have applied tax class on some products. I need rounded price for grand total because product prices are not in decimal value. – Aks Jun 30 '17 at 17:02
0

check this file from core

Mage_Sales_Model_Quote_Address_Total_Grand

/**
     * Collect grand total address amount
     *
     * @param   Mage_Sales_Model_Quote_Address $address
     * @return  Mage_Sales_Model_Quote_Address_Total_Grand
     */
    public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        $grandTotal     = $address->getGrandTotal();
        $baseGrandTotal = $address->getBaseGrandTotal();

        $store      = $address->getQuote()->getStore();
        $totals     = array_sum($address->getAllTotalAmounts());
        $totals     = $store->roundPrice($totals);
        $baseTotals = array_sum($address->getAllBaseTotalAmounts());
        $baseTotals = $store->roundPrice($baseTotals);

        $address->setGrandTotal(round($grandTotal+$totals)); // round here
        $address->setBaseGrandTotal(round($baseGrandTotal+$baseTotals)); // round here
        return $this;
    }

    /**
     * Add grand total information to address
     *
     * @param   Mage_Sales_Model_Quote_Address $address
     * @return  Mage_Sales_Model_Quote_Address_Total_Grand
     */
    public function fetch(Mage_Sales_Model_Quote_Address $address)
    {
        $address->addTotal(array(
            'code'  => $this->getCode(),
            'title' => Mage::helper('sales')->__('Grand Total'),
            'value' => $address->getGrandTotal(),
            'area'  => 'footer',
        ));
        return $this;
    }

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.