This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ugiftcert:troubleshooting:debug-incorrect-totals [2013/11/26 20:29] jamby77 created |
ugiftcert:troubleshooting:debug-incorrect-totals [2013/11/26 20:34] (current) jamby77 [Solution] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Debug incorrect totals ====== | ||
+ | |||
+ | ==== Problem ==== | ||
+ | |||
+ | When Gift code is added to cart, some taxes are not deducted from total even if certificate amount is enough. | ||
+ | |||
+ | ==== Reason ==== | ||
+ | |||
+ | The cause for this issue is the way totals are calculated for cart. | ||
+ | Gift total should be calculated last before grand total and if it is put out of order and is not second to last end result is wrong. | ||
+ | For example if tax is calculated after gift total, it will not be covered by gift. | ||
+ | Reason for this order issue is how Magento orders totals. | ||
+ | The order is defined in config.xml files. For giftcert it is: | ||
+ | |||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | In the snippet above, '' | ||
+ | |||
+ | Similar code is defined for the other totals. Then all configs are merged and sorted by Magento. And during the sorting process is where the issue happens. | ||
+ | If there are race settings like few totals declaring to be ''< | ||
+ | |||
+ | Usually cause for this misalignment is addition of a new total. | ||
+ | |||
+ | ==== Solution ==== | ||
+ | |||
+ | To fix the sorting, first we need to find which total causes the misalignment. | ||
+ | To do that we need to log totals in order Magento sees them. | ||
+ | For this we need to add some logging to a core file. | ||
+ | **/ | ||
+ | <code php> | ||
+ | public function collectTotals() | ||
+ | { | ||
+ | foreach ($this-> | ||
+ | $model-> | ||
+ | } | ||
+ | return $this; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | To find order of totals, we change above code as follows: | ||
+ | |||
+ | <code php> | ||
+ | public function collectTotals() | ||
+ | { | ||
+ | Mage:: | ||
+ | foreach ($this-> | ||
+ | Mage:: | ||
+ | $model-> | ||
+ | } | ||
+ | return $this; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This will log codes of all totals in **var/ | ||
+ | Or you can check it yourself. Find if any totals appear between '' | ||
+ | When potential problems are identified, we need to try and fix them. We do that by editing the config.xml files in the total declaration part. | ||
+ | Unfortunately there is no guaranteed fix, and it is trial and error process. | ||
+ | Disable config cache in admin and then edit the sections for offending totals. | ||
+ | |||
+ | For example, we have change **/ | ||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <!-- Node bellow is added to fix a Magento bug, which is causing improper ordering of totals --> | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <tax> | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <!-- End fix magento bug--> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | You can try fixes for any suspicious totals in the same file. | ||
+ | |||
+ | Since this could be tricky to figure out by your selves, you can gather some preliminary data and send it to us along with FTP access to try to fix the issue for you. | ||