1

I am using this extension for adding extra fees,

In checkout page,

enter image description here

Order total before creating invoice,

enter image description here

After creating invoice,

enter image description here

Error : The invoice total and order total not matching in invoice,

enter image description here

Customer feel order total & invoice total different, How to manage this case?

FYI - If i try with fresh magento, extra fees showing on order total in order page and invoice & order also same total.

1
  • I had the same problem, had to hire a developer to fix it, that extension is incomplete and has other problems
    – PaddyD
    Commented Sep 13, 2019 at 11:47

1 Answer 1

0

in the config.xml file you need to add the below code in tag

<adminhtml>
                <rewrite>
                    <sales_totals>Voronoy_ExtraFee_Block_Adminhtml_Sales_Totals</sales_totals>
                    <sales_order_totals>Voronoy_ExtraFee_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
                    <sales_order_invoice_totals>Voronoy_ExtraFee_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
                </rewrite>
            </adminhtml>

create new file Totals.php at Voronoy/ExtraFee/Block/Adminhtml/Sales folder

<?php

class Voronoy_ExtraFee_Block_Adminhtml_Sales_Totals extends Mage_Adminhtml_Block_Sales_Totals
{
    protected function _initTotals()
    {
        parent::_initTotals();
        $source = $this->getSource();

        $totals = $this->_totals;
        $total = array();
        if (count($totals) > 0) {
            foreach ($totals as $index => $val) {
                if ($index == "grand_total") {
                    if (((float)$this->getSource()->getExtraFeeRuleAmount()) != 0) {
                        $label = $this->__('Extra Fee');
                        $total['extra_fee_rule_amount'] = new Varien_Object(array(
                            'code' => 'extra_fee_rule_amount',
                            'field' => 'extra_fee_rule_amount',
                            'value' => $source->getExtraFeeRuleAmount(),
                            'label' => $label
                        ));
                    }


                }
                $total[$index] = $val;
            }
            $this->_totals = $total;
        }

        return $this;
    }
}

create file Totals.php at Voronoy/ExtraFee/Block/Adminhtml/Sales/Order/

<?php

class Voronoy_ExtraFee_Block_Adminhtml_Sales_Order_Totals extends Voronoy_ExtraFee_Block_Adminhtml_Sales_Totals
{
    protected function _initTotals()
    {
        parent::_initTotals();
        $this->_totals['paid'] = new Varien_Object(array(
            'code' => 'paid',
            'strong' => true,
            'value' => $this->getSource()->getTotalPaid(),
            'base_value' => $this->getSource()->getBaseTotalPaid(),
            'label' => $this->helper('sales')->__('Total Paid'),
            'area' => 'footer'
        ));
        $this->_totals['refunded'] = new Varien_Object(array(
            'code' => 'refunded',
            'strong' => true,
            'value' => $this->getSource()->getTotalRefunded(),
            'base_value' => $this->getSource()->getBaseTotalRefunded(),
            'label' => $this->helper('sales')->__('Total Refunded'),
            'area' => 'footer'
        ));
        $this->_totals['due'] = new Varien_Object(array(
            'code' => 'due',
            'strong' => true,
            'value' => $this->getSource()->getTotalDue(),
            'base_value' => $this->getSource()->getBaseTotalDue(),
            'label' => $this->helper('sales')->__('Total Due'),
            'area' => 'footer'
        ));
        return $this;
    }
}

create file Totals at Voronoy/ExtraFee/Block/Adminhtml/Sales/Order/Invoice/ folder

<?php

class Voronoy_ExtraFee_Block_Adminhtml_Sales_Order_Invoice_Totals extends Voronoy_ExtraFee_Block_Adminhtml_Sales_Totals
{
    protected $_invoice = null;

    public function getSource()
    {
        return $this->getInvoice();
    }

    public function getInvoice()
    {
        if ($this->_invoice === null) {
            if ($this->hasData('invoice')) {
                $this->_invoice = $this->_getData('invoice');
            } elseif (Mage::registry('current_invoice')) {
                $this->_invoice = Mage::registry('current_invoice');
            } elseif ($this->getParentBlock()->getInvoice()) {
                $this->_invoice = $this->getParentBlock()->getInvoice();
            }
        }
        return $this->_invoice;
    }

    protected function _initTotals()
    {
        parent::_initTotals();
        $total = 0;


        $this->_totals['grand_total'] = new Varien_Object(array(
            'code' => 'grand_total',
            'strong' => true,
            'value' => ($this->getSource()->getGrandTotal() + $total),
            'base_value' => ($this->getSource()->getBaseGrandTotal() + $total),
            'label' => $this->helper('sales')->__('Grand Total'),
            'area' => 'footer'
        ));
        return $this;
    }
}
6
  • I just try with fresh magento its working, may i know how to find my error and solve it instead of doing changes in files?
    – zus
    Commented Sep 14, 2019 at 4:53
  • in that extension if you want to add extra fee line than you need to override total block Commented Sep 14, 2019 at 4:58
  • But my fresh magento showing extra fees in my order total without override any block.
    – zus
    Commented Sep 14, 2019 at 5:07
  • How to debug my case?
    – zus
    Commented Sep 14, 2019 at 5:07
  • which magento version are you using? Commented Sep 14, 2019 at 6:38

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.