I have a following problem:
There is a 3rd party extension which automatically adds products to cart as gifts when user adds some specific product. It also applies coupon. For example it adds free WiFi receiver when user wants to buy a TV. It adds products good enough, but there must be a shopping cart rule to make a 100% discount for these products.
What I need to do is to make this extension to add these products as free without shopping cart rule. The only event i found connected with discounts is sales_quote_address_discount_item, but any operations with it gave no results.
So I would be really grateful if someone points me in the right direction: where exactly in code is this discount applied and how can I make the same from this extension?
The discount from a coupon is applied in
Mage_SalesRule_Model_Validatorin theprocess()method. This method is called every timecollectTotals()is called on the quote. You would need to override this class (and possible a few others) to override coupon behavior. There is an event inside that methodsalesrule_validator_processthat you might be able to use instead of overriding the whole method, but it will depend on what logic you need to change as to whether it occurs at the right place for you.