TL:DR - trying to change the order that totals are collected doesn't work as expected. How do I adjust the order they are processed properly?
I previously had a problem with a custom total breaking the tax total, and found the problem was the order that totals are added in sales/quote/address/total/collector.php getCollectors().
on my working modules config.xml I use:
<quote>
<totals>
<fee>
<class>fee/sales_quote_address_total_fee</class>
<before>subtotal</before>
</fee>
</totals>
</quote>
on another install the module, using the same config.xml doesn't work.
after some debugging and testing I confirmed that the problem is this bit of code (when it's used the taxes don't calculate correctly, when it's commented out it does), and it seems the problem is that on the working install changing the "before" node changes the order, but on the non-working it doesn't behave as expected.
I need my total to be added before the subtotal, but below you can see some examples of what it is doing on both the working install and the non-working install.
So my questions are: On the non-working install, why is my fee being added to the totals so late, even though it's set to before subtotal?
Is there another way to adjust the order they are collected?
Is there anything that might over-ride or alter the order they should be collected?
how can I get my total to collect before the subtotal, like I want it to?
What I did so far -
I made a simple controller with the following:
$collectors = Mage::getModel('sales/quote_address_total_collector')->getCollectors();
Zend_Debug::dump(array_keys($collectors));
and have run it in the following situations with the following results(please take not of the total "fee" which is mine):
working install with fee set to <after>subtotal</after>
(breaks the install, but here to show that I can adjust the order and it shows up where it should)
array (size=12)
0 => string 'nominal' (length=7)
1 => string 'subtotal' (length=8)
2 => string 'msrp' (length=4)
3 => string 'fee' (length=3)
4 => string 'freeshipping' (length=12)
5 => string 'tax_subtotal' (length=12)
6 => string 'weee' (length=4)
7 => string 'shipping' (length=8)
8 => string 'tax_shipping' (length=12)
9 => string 'discount' (length=8)
10 => string 'tax' (length=3)
11 => string 'grand_total' (length=11)
working install with fee set to <before>subtotal</before>
array (size=12)
0 => string 'nominal' (length=7)
1 => string 'fee' (length=3)
2 => string 'subtotal' (length=8)
3 => string 'msrp' (length=4)
4 => string 'freeshipping' (length=12)
5 => string 'tax_subtotal' (length=12)
6 => string 'weee' (length=4)
7 => string 'shipping' (length=8)
8 => string 'tax_shipping' (length=12)
9 => string 'discount' (length=8)
10 => string 'tax' (length=3)
11 => string 'grand_total' (length=11)
nonworking install with fee set to <before>subtotal</before>
(should work)
array(13) {
[0] => string(7) "nominal"
[1] => string(8) "subtotal"
[2] => string(12) "tax_subtotal"
[3] => string(12) "tax_shipping"
[4] => string(3) "fee"
[5] => string(11) "aw_giftwrap"
[6] => string(12) "freeshipping"
[7] => string(8) "shipping"
[8] => string(4) "weee"
[9] => string(8) "discount"
[10] => string(11) "grand_total"
[11] => string(4) "msrp"
[12] => string(3) "tax"
nonworking install with fee set to <after>subtotal</after>
array(13) {
[0] => string(7) "nominal"
[1] => string(8) "subtotal"
[2] => string(12) "freeshipping"
[3] => string(12) "tax_subtotal"
[4] => string(12) "tax_shipping"
[5] => string(11) "aw_giftwrap"
[6] => string(8) "shipping"
[7] => string(3) "fee"
[8] => string(4) "weee"
[9] => string(8) "discount"
[10] => string(11) "grand_total"
[11] => string(4) "msrp"
[12] => string(3) "tax"