I had to replicate coupon functionality in which the user can able to apply the coupon code and see the discount price in product page itself before adding that product to cart.
So i used ajax call to load the coupon code , its rule conditions by like the following way
<?php
-----
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponcode, 'code');
if($oCoupon){
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
$rule_arr = unserialize($oRule->getConditionsSerialized());
$actions_serialized = unserialize($oRule->getData("actions_serialized"));
$conditions = $rule_arr['conditions'];
foreach($conditions as $condition){
$conditions1 = $condition['conditions'];
$type = $condition['type'];
foreach($conditions1 as $condition1){
$type = $condition1['type'];
$value = $condition1['value'];
}
}
}
}
----
Here i validated every possible rule - but still its not validating all defined rules and its not stable.
Is there anyway I can able to validate a product and coupon rules - or is there any extension which does validation against one product and coupon rules. Please help me