I have made a coupon [coupon_code = SWIMFREE]
if category
is swimming equipment
and hobby
is swimming
will be discount b
already found the answer by myself:
It is possible to create a customized coupon condition.
rewrite the Mage_SalesRule_Model_Rule_Condition_Product
public function validate(Varien_Object $object){
if ($this->getAttribute() == 'quote_item_with_hobby') {
$quote = Mage::getSingleton('checkout/cart')->getQuote();
$hobby= $quote->getHobbyByItemId($object->getId());
if ($hobby){
if ($this->getOperator() == '=='){
if (strtolower($this->getValue()) == $hobby->getHobby()) return true;
else return false;
}
else if ($this->getOperator() == '!='){
if (strtolower($this->getValue()) == $hobby->getHobby()) return false;
else return true;
}
}
return true;
}
return parent::validate($object);
}
this function will be called every step loaded. then checked if return true, then the coupon will be applied, if return false then the coupon won't be applied.
Thank's to All Who Participated. i appreciate it.