Magento News

 

Questions About Creating An Order Total In Magento

I am attempting to create an order total module to do some custom price adjustments. Just to get started with this I am just trying to get it to add $20 to every single order (eventually putting in the real logic).

I am having issues with the module that I created. The first issue is that it appears to be running twice (so it is taking $40 off instead of only $20 — Logging showed me that both the collect and fetch methods are being run twice)

The second issue is that the discount line item is appearing below the Grand Total line.

Can someone tell me what I am doing wrong here? The contents of my config.xml and order total class are below.

config.xml Content

<global>
    <sales>
        <quote>
            <totals>
                <mud>
                    <class>Wpe_Multiunitdiscount_Model_Multiunitdiscount</class>
                    <before>grand_total</before>
                </mud>
            </totals>
        </quote>
    </sales>
</global>

Wpe_Multiunitdiscount_Model_Multiunitdiscount Content

class Wpe_Multiunitdiscount_Model_Multiunitdiscount extends Mage_Sales_Model_Quote_Address_Total_Abstract {

public function collect(Mage_Sales_Model_Quote_Address $address) {
    $address->setGrandTotal($address->getGrandTotal() + 20 );
    $address->setBaseGrandTotal($address->getBaseGrandTotal() + 20);
    return $this;
}

public function fetch(Mage_Sales_Model_Quote_Address $address) {
    $address->addTotal(array(
        'code'  => $this->getCode(),
        'title' => Mage::helper('sales')->__('Super Tax'),
        'value' => 20,
    ));
    return $this;
}

}

Questions About Creating An Order Total In Magento

Possibly Related Posts:


 

Leave a Reply