I finally managed to complete the task, and for future reference, I explain the procedure here.
The class mentioned in the question (i.e.: Mage_SalesRule_Model_Rule_Condition_Address) is the key to the problem. I had to rewrite it and for some odd reason, I could not get what I needed by extending it so that my class extends the parent class (e.g. Mage_Rule_Model_Condition_Abstract).
As I said, I added my attribute to $ attributes as follows:
'net_score' => Mage::helper('mymodule')->__('Net Score')
I also modified the getInputType () method and declared my attribute as numeric
now what the trick is the validate () method:
public function validate(Varien_Object $object) { $address = $object; if (!$address instanceof Mage_Sales_Model_Quote_Address) { if ($object->getQuote()->isVirtual()) { $address = $object->getQuote()->getBillingAddress(); } else { $address = $object->getQuote()->getShippingAddress(); } } if ('payment_method' == $this->getAttribute() && ! $address->hasPaymentMethod()) { $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod()); } return parent::validate($address); }
as you can see, it prepares an instance of Mage_Sales_Model_Quote_Address and sends it to its parent validation method. you can see that this object ($ address) does not have a payment_method method by default, therefore this method creates it and assigns it. So I did the same, I just added the following code before returning:
if ('net_score' == $this->getAttribute() && ! $address->hasNetScore()) { $address->setNetScore( ); }
and now I can set the rules for this attribute.
We hope that this information will save someone time in the future.
source share