Thursday, January 5, 2012

Apply coupon discount on Original Price not on special price in magento programmatically


In Magento Default coupon code will apply to special price if special price is there else it will apply to original price ,
but in some case we need to apply coupon code discount to original price and then apply to special price
EX:- Special price 1000
Original Price :- 2000
Coupon discount is 10%

Then in cart page it will show special price- discountamount( acc to special price) i't 1000-100 = 900

but we need special price- discountamount( acc to Original price) i'e 1000- 200 =800

for that we need to create a event

add this xml code in config.xml in side events tag i'e <events></events>

<!-- event for default coupon but discount will apply for MRP-->

And created Observer.php inside your module/model if not exists else add only this function newcoupondiscountcal($observer) in side Observer class

class Namespcae_Modulename_Model_Observer

//event for default coupon but discount will apply for MRP
public function newcoupondiscountcal($observer)

$rulePercent = max(0, 100-$rule->getDiscountAmount());
//print_r($rule->getData()); exit;

if($rule->getSimpleAction()=='by_percent') {

$result = $observer['result'];


clear cache and apply the code

No comments:

Post a Comment