I want to create coupon code and I need to set also expiration date. Magento offers to set expiration date only for promotion rules and it affects globally all coupons inside this rule. Anyway inside database table salesrule_coupon has also field expiration_date but it seems that this field is not used anywhere.

Has anybody managed to set expiration date for individual coupon successfully? Otherwise I am thinking the only way to make it right would be to create observer which will observe entering coupon code and delete the coupon if expired and thus it will make coupon code unusable before it is applied.

Any ideas are appreciated.

2 Answers 2


I have not found any solution for it, But I have used an alternate way to achieve it.

  1. create rule which will be always expired by date.
  2. push condition based coupon codes to it based on cron.


$couponCode = 'XZY';//auto-generated code or get collection of auto-generated               codes from a rule.
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');

$ruleName = 'referral_expired'; //existing rule with this name
$shoppingRule = Mage::getResourceModel('salesrule/rule_collection')->addFieldToFilter('name',$ruleName)->load()->getFirstItem();
$shoppingRuleId = $shoppingRule->getRuleId();

If I understand you correctly, you want to set expiring date for your coupon.

Then this function should be already available in magento.

Check this screenshot:

enter image description here

Go to Promotions > Shopping cart price rule and choose your desired rule or create new one.

At the bottom of the Rule Information Section you will see this setting. Simply enter the date for To Date and it will expire on that date.

Hope this helps.

  • 1
    I need for individual coupon, not for all coupons together. Inside rule I auto generate coupon codes and each coupon code should have different To Date. The functionality Magento gives will set To Date for all coupons inside the same rule the same.
    – JohnyFree
    Commented Aug 6, 2015 at 20:01
  • In that case, you should create diff coupon for same item with diff exp date. Commented Aug 6, 2015 at 23:24
  • 1
    I need all coupon codes to be inside the same price rule, I don't want to have thousands of price rules. And Magento doesn't offer you to create expire date per coupon but only per price rule.
    – JohnyFree
    Commented Aug 7, 2015 at 8:19

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.