I'm looking for place at code where shopping cart price rules are applied. Lets say, I've created a rule and when I add some product to shopping cart which match this rule, this rule will be applied and can change a price. I'm trying to explore module SalesRules
, but without success. Maybe someone can give me a right direction?
Add a comment
|
1 Answer
The starting point for all salesrules are in the Observer:
\Mage_SalesRule_Model_Observer::sales_quote_address_discount_item()
There \Mage_SalesRule_Model_Validator::process()
is called, where it is checked whether the rule should be applied:
if (!$this->_canProcessRule($rule, $address)) {
continue;
}
if (!$rule->getActions()->validate($item)) {
continue;
}
and afterwards the discounts are applied.
I hope this helps you on your way into the salesrules.
-
I am confused in your answer what should i write in my observer?i just want to check one flag from quote and if it is false then i don't want to apply rule.How can i achive this using observer? Commented Jan 29, 2019 at 12:46
-
Sorry but I don't understand the question. To get the quote you can call
Mage::getSingleton('checkout/quote')
and check for the flag. Commented Jan 29, 2019 at 15:33 -
I know that i can get quote flag like that but here i m asking that when my flag is false then i would like to stop applie rule on that quote. For that what should i do Commented Jan 30, 2019 at 5:40
-