I have to retrieve the rule associated to a coupon code in order to display in quote the discount percentage of that rule. the simplest way is to calculate directly from quo
May be this solution will help you to get couponcode amount by coupon code.
$couponCode = 'YOUR COUPONCODE';
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
print_r($oRule->getData());exit();
First get the coupon code
$orderNumber = 100000105; //order number with coupon code
$order = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);
$orderDetails = $order->getData();
$couponCode = $orderDetails['coupon_code'];
Then use solution by Jürgen Thelen.
To load a coupon by code, pass 'code'
as 2nd param to load()
. Then you can get the proper rule instance by using the rule_id
value of your coupon instance:
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
var_dump($oRule->getData());