I am using the Drupal Commerce module and I have a product type service for license to be sold on site. I have different licences (products) like 1 year license, 2 year license, 6 months license and many more.

I need to send an email to customers 1 month prior to their license expiration date. Like if customer purchased a license for 1 year, then the email should be sent 11 months after date of purchase. Similarly with other products like after 5 months if license is for 6 months.

How can I achieve this using the Rules module?

  • 1
    What did you try? What happened?
    – Clive
    Jan 31, 2017 at 14:14

2 Answers 2


Answering my own question.

I have finally done this using hook_default_rules_configuration() I have created a test rule with static values, then exported it and used the hook mentioned above to modify the values on run time.

This worked best for my requirements.


Use the Rules Scheduler (a sub-module of the rules module) for sending such eMails.

You would have to create a Rules Component (to actually send an appropriate eMail) and a rule (which schedules that Rules Component), which is similar to the exported rules shown in my answer to "How to send an email to an author on a specific date using date field specified in a node?". Just replace the "field_weaning_date" by what corresponds to your "1 month before expiration date".

If you don't have an expiration date, you could also use something like "order creation date", and combine that with (eg) "after 5 months from now" (for a license of 6 months). And if in the same rule you'd want to combine this logic for licenses that expire after 6 months, or 1 year, or 2 years, you can do so by using either the Conditional Rules module, or a Rules Component (in which you include Rules Conditions about the expiration date).

Obviously, you'd want to use some Rules Event that corresponds to something like your "Customer purchases license".

PS: I'm assuming this question is about D7.

  • I don't have License expiration date, expiration date is only dependent on Order creation date, what needs to be calculated from order creation date is date to send the reminder, which can be different, particularly there is not expiration date, I only have order creation date and product of type service. Feb 1, 2017 at 7:42
  • Your answer was useful to me but it did not fixed the issue, I have done this programmatically using hook_default_rules_configuration(). Thank you for your help. Feb 2, 2017 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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