I've added an additional fee (for prepaid customs and duty) based heavily on this tutorial at excellencemagentoblog.com.

I thought I had it working, but now that a few people are using it in the wild, we've discovered a problem.

When there are other fees outside the ones normally displayed, then the whole collect totals thing breaks. For example, if a merchant uses a cart rule that gives a discount based on subtotal, the discount doesn't show, my fee doesn't show, and the grand total is wrong (it's not the total without the discount and fee, and it's also not the correct total with them).

If I remove the collector from the config.xml, then everything goes back to how it should, but obviously my additional fee doesn't work anymore.

Because of the checkout process followed (programatically created order after 3rd party hosted checkout), I really don't need my additional fee run in the cart or visible in the quote, only in the order views, invoice, etc.

Collect totals is far from my expertise so I appreciate any help. I'm happy to post any code that might help. Just let me know what you'd like to see. most of it follows very closely the tutorial, with just some additional logic to determine the amount and if it applies.

  • Unfortunately separating out the customs and duty isn't an option with the business model. I'm sure there is a way to extend the collectTotals to allow additional line-items such as my fee, because i've seen it done. I just don't have access to the extensions to see how. Edit: actually we calculate them in realtime also, but on the hosted checkout. that's one of the major services they provide.
    – Matt Flamm
    Commented Sep 29, 2014 at 13:25
  • I don't completely understand what you mean. All I'm trying to do is add a total without causing errors in cart-rule discounts and tax rule calculations. The business part of it was decided before this project even started.
    – Matt Flamm
    Commented Oct 3, 2014 at 12:53

1 Answer 1


The problem was specifying the order of totals. In this case I needed to add


to each total definition in the config.xml, for example:


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.