1

I need to check to see if a coupon code is correct in an ajax controller, how is this done?

I get the code like this:

$param['code'];

1 Answer 1

3

Try

couponCode = $param['code'] 
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());

Then try to apply it to your order see Check if coupon is valid for a quote

2
  • try to apply oRule with setCouponCode? Commented Feb 10, 2015 at 20:00
  • Suppose a coupon os valid until yesterday and I would execute this code. Would it then return an error or empty? Commented Mar 18, 2016 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.