Read below. I think this helps you a lot: -
See address below
http://www.excellencemagentoblog.com/magento-add-fee-discount-order-total
Magento Add total amount or discount
In this tutorial, we will see how to add a new line item to magento totals. This means that how to add an additional fee or discount, or any type of charging the order amount to the purple process. In a typical order, the total order amounts usually include: “Total”, “Delivery cost”, “Taxes”, “Discount”, based on these values, the total amount of orders is calculated. Now, if we want to add an additional charge on a credit card or a discount on a discount or a discount on an affiliate program or any other order amount that will affect the total order quantity, we need to create a magenta module. This additional fee, which we add to the total amount, will be reflected in
- Place an order to order
- Cart Order page Total
- My Account View Account
- Order EMails
- View Admin Order / Email / PDF
- View Admin Invoice / Email / PDF
- View Credit Loan Admin / Email / PDF
as you can see from the above list, this module is not simple. In this tutorial, I attach the source of such a very basic module that you can use as a starting point to add additional changes. I will also explain the basics of how to implement this. In this tutorial, I will add a new number of orders called a $ 10 fixed cost fee.
Or try:
Place an order Total amount of total orders
We will see how to add totals only to the verification page. All summary items displaying the verification page come from files located in the folder Mage \ Sales \ Model \ Quote \ Address \ Total. In purple, before placing an order, all order data is stored in the quotation object and, after placing the order, it is transmitted to the order object. The resulting quotes follow the pattern of the collector, and we can add collectors as many collectible classes. To add a collector to the quote object in our config.xml file, we add lines
<global> <sales> <quote> <totals> <fee> <class>fee/sales_quote_address_total_fee</class> </fee> </totals> </quote> </sales> </global>
This means that whenever the totals are computed for a quote, it also calls this class. All collectors are called from the collectTotals () function in the Quote model. In our collector class, we enter the code
<?php class Excellence_Fee_Model_Sales_Quote_Address_Total_Fee extends Mage_Sales_Model_Quote_Address_Total_Abstract{ protected $_code = 'fee'; public function collect(Mage_Sales_Model_Quote_Address $address) { parent::collect($address); $this->_setAmount(0); $this->_setBaseAmount(0); $items = $this->_getAddressItems($address); if (!count($items)) { return $this; //this makes only address type shipping to come through } $quote = $address->getQuote(); if(Excellence_Fee_Model_Fee::canApply($address)){ //your business logic $exist_amount = $quote->getFeeAmount(); $fee = Excellence_Fee_Model_Fee::getFee(); $balance = $fee - $exist_amount; $address->setFeeAmount($balance); $address->setBaseFeeAmount($balance); $quote->setFeeAmount($balance); $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount()); $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount()); } } public function fetch(Mage_Sales_Model_Quote_Address $address) { $amt = $address->getFeeAmount(); $address->addTotal(array( 'code'=>$this->getCode(), 'title'=>Mage::helper('fee')->__('Fee'), 'value'=> $amt )); return $this; } }
The two main functions here are collect () and fetch (). In the collection function, you add any amount that you want to receive in the total amounts of the order, and the fetch () function is used for display. If done correctly, you should see your general order line on the checkout and cart page. Here we use two fields fee_amount and base_fee_amount, which contain our fee amount. We will need to save these two fields in the database, so in our module installer file we will add this code
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL; ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
Order page
So far, all written code has been executed only for the citation object. But after placing the order, we need to transfer all the information to the order object. As you saw above, we use the two fields fee_amount and base_fee_amount, now we also need to save these two fields in the order table. To do all of the above, we need to do two things. First, in the config.xml file, add this code inside the global tab,
<fieldsets> <sales_convert_quote_address> <fee_amount><to_order>*</to_order></fee_amount> <base_fee_amount><to_order>*</to_order></base_fee_amount> </sales_convert_quote_address> </fieldsets>
and in our module installation file
ALTER TABLE `".$this->getTable('sales/order')."` ADD `fee_amount` DECIMAL( 10, 2 ) NOT NULL; ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_fee_amount` DECIMAL( 10, 2 ) NOT NULL;
After that, these two fields should be saved in the order table from the quote table.
These are just the basics of adding a line item to order everything. There is still a lot of code written inside the attached module, please read it in detail to understand more.