1

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?

0

1 Answer 1

4

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.

4
  • 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?
    – MageLerner
    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
    – MageLerner
    Commented Jan 30, 2019 at 5:40
  • Please mention the file path Commented May 5, 2020 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.