0

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 Sep 29 '14 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 Oct 3 '14 at 12:53
0

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

<after>tax</after>

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

<quote>
    <totals>
          <fee>
                <class>my_class</class>
                <after>tax</after>
          </fee>
    </totals>
</quote>
| improve this answer | |

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.