I'm trying to add an oversized fee for large products. Most of what that entails is a little more complicated than I want to explain here. Basically, I've built a custom function to check if the product is oversized and assign the appropriate shipping cost. However, I can't figure out how to get that value added into the grand total at check out.

  • "I've built a custom function to check if the product is oversized and assign the appropriate shipping cost." do you really set shipping charge? If so as said by fooman, it will automatically get added to grand total. – Shathish Jul 17 '13 at 5:05
  • 1
    No, it's an additional charge that we need to have show up separately from shipping. – eisaacson Jul 17 '13 at 15:39

Magento automatically combines the subtotal and grandtotal of the addresses for you, see Mage_Sales_Model_Quote::collectTotals

        $this->setSubtotal((float) $this->getSubtotal()+$address->getSubtotal());
        $this->setBaseSubtotal((float) $this->getBaseSubtotal()+$address->getBaseSubtotal());

        $this->setGrandTotal((float) $this->getGrandTotal()+$address->getGrandTotal());
        $this->setBaseGrandTotal((float) $this->getBaseGrandTotal()+$address->getBaseGrandTotal());

Adding your extra charge to the address subtotal and grandtotal will ensure it is reflected in the overall grand total.

For more in depth reading on the checkout process I can thoroughly recommend this post by Chris @ Classy Llama.

  • Will this get passed to Paypal Express in a manner that doesn't cause the infamous NVP Gateway reject? – Fiasco Labs Jul 17 '13 at 0:27

Please have a look at http://www.excellencemagentoblog.com/magento-add-fee-discount-order-total
This tutorial may fulfill your requirement.


I will second @Fooman's recommendation of the blog series on collect totals... won't claim to not be biased though since I do, after all, work with the author of the series. ;)

That said, Web Shop Apps has pre-existing modules for almost anything shipping related. And from the sound of it, one perfectly suited to your needs. The Handling Fees Matrix module in particular sounds it could serve your needs well without any custom development. Simply install, setup the matrix rules to apply the added handling fee and voila!

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.