I have a module (not created by me) which picks up a quote and applies a discount if certain criteria are met. This works fine on it’s own. The shopping cart rules also work fine on their own.
However, I need the custom module to apply relevant discounts before the built in Magento shopping cart (total price) rules are applied. As it stands the Magento ones apply first, and then the custom ones, leading to Magento discounts when there shouldn’t be.
What controls the order of the modules, and thus how would I specify a different order.
Magento has the
collectTotalsfunctional (I believe this is realization of the Composite pattern). What it basicly does – is address each of the specified Totals Collectors in order and call it’scollect()method.Most likely the total collector for your module is called after the
SalesRuleone (which has code discount). So what you need to do: open theconfig.xmlconfiguration file of the custom discount module, find the xpath config/global/sales/quote/totals/[the module alias] and add (or change if it exists) the directive<before>discount</before>In that way you’re ordering the total collector of the custom module to apply discounts before the
SalesRuleone.