0

In Mage_SalesRule_Model_Validator::process(), it checks whether or not the available shopping cart rules apply to items in the shopping cart via $this->_canProcessRule($rule, $address)).

_canProcessRule() in turn checks $rule->hasIsValidForAddress($address) (Mage_SalesRule_Model_Rule), which returns false for a particular item I have in my cart, and the shopping cart rule does not apply. The item I have is a simple product that is added from a grouped product page. The simple product is not visible. $rule->hasIsValidForAddress($address) returns true if this simple product is added to cart from an associated with a configurable product.

UPDATE:

The shopping cart price rule I have is simple. Take $1 off from the cart if any of the product in the cart is in category X. The grouped item is visible in Catalog,Search and the associated simple products are Not Visible.

I later realized that shopping cart rules do not apply to Not Visible products, which in my case as the simple products that don't need to be visible since they're associated with a grouped product (configurable-simple products behave differently when being purchased). I made a separate post regarding this HERE.

So, why is this checking $address (Mage_Sales_Model_Quote_Address)? I'm still not clear why this simple product does not have a validated address.

2
  • Did you manage to make any progress with your question? Commented Mar 6, 2014 at 12:28
  • No, I haven't made any progress beyond my updated post.
    – laketuna
    Commented Mar 6, 2014 at 14:51

1 Answer 1

2

The address is used to tie part of the validation to since it holds the customer object. If you look at the points where it is decided to return true or false it ties directly into the customers usage of a certain coupon. The method hasIsValidForAddress is a caching mechanism. If you check further down in the _canProcessRule method the setIsValidForAddress is called to fill this cache for future use.

Why it prevents the rule from being applied to your particular product is hard to say with extra information like the rule and the data of the product it should be applied to. It sounds like there's another issue but that's just a feeling I have coming from your story

1
  • I see the caching mechanism before checking coupon and rule limitations in _canProcessRule(). I updated my question to what I've find since then and added more details as well.
    – laketuna
    Commented Mar 6, 2014 at 14:53

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.