I have added a new custom subtotal to my totals in Magento CE Each item in my shopping cart may have a different surcharge to avoid losses due to fluctuations in value. This is common in the industry that these surcharges are calculated and presented separately. A helper class calculates this value for each item and only show it under the final price without taxes in the template. Later, the surcharges will be added together and shown as a subtotal below. It looks good so far and everything works as it should, except the calculation of taxes. The tax calculation uses the subtotal as a basis and not the subtotal plus the surcharges, as you can see in the snapshot of the shopping cart below. The yellow arrow shows what i want, the red one is the wrong calculation basis. I expect the VAT amount to be 3.86€ (19% of 19,86€ + 0,47€) and not 3.77€ (19% of 19,86€). So the taxes are too low.

wrong tax calculation in cart

I've done all this as described in this blog with a few modifcations: https://astrio.net/blog/magento-development-add-total-row-checkout/

My config.xml:


As you can see, I want to add this custom total (surcharge) before the subtotal, right after the start.


And I want to show it as the first total in the list (subtotal has the value 10, so 5 is lower). In the admin backend the tax calculation method based on pos. subtotal.

How can I force the "VAT total" to take the surcharge into account?

If you need more information, let me know and thank you in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.