0

When a subscriber’s monthly subscription is due for renewal, an automatic email should go to that user stating that the renewal is due. There will be two possibilities:

  1. If there is no response to the notification, automatically the CC will be charged as per the current package selected.

  2. The automatic eMail notification will have a link to upgrade to a different package if the subscriber wants to.

How to achieve this?

1 Answer 1

0

Part 1 - Sending eMail notifications

Use the Rules module together with Rules Scheduler (a sub-module of it), as explained in the steps below. These steps are based on a date field which is added to the user profile, so that for each user you can indicate an appropriate renewal date of a specific package. To support multiple packages, just create similar date fields (1 for each package type).

Step 1: Create a field to store the renewal date

Add a field to the "user" entity with machine name (say) field_next_renewal. Allow only 1 date (to store the "next" renewal).

Step 2: Create a Rules "Component"

Here is the Rules Component to be created (in Rules export format, just import it in your own environment via copy-paste):

{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Friendly reminder about your upcoming renewal",
          "message" : "This is a reminder about the upcoming renewal  on [user-to-notify:field_next_renewal] ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Message of the eMail may need review / tuning, while you might also want to use some other From eMail ID. The Message-part of it is also where you can add the "link to upgrade to a different package" (as in your question).

Step 3: Create a "Rule" using the Rules Component

Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste):

{ "rules_on_user_renewal" : {
    "LABEL" : "On user renewal",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_renewal" } }
    ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_send_email_notification",
          "task" : "[account:name]"
        }
      },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : {
            "select" : "account:field-next-renewal",
            "date_offset" : { "value" : 259200 }
          },
          "identifier" : "[account:name]",
          "param_user_to_notify" : [ "account" ]
        }
      }
    ]
  }
}

Note that the above rule refers to the Rules Component from the previous step. It gets triggered any time a user profile is updated (feel free to replace that Rules Event with any other event that might fit).

The schedule_delete that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recent date).

Step 4: additional refinements

  • The date_offset (=259200) in the above rule corresponds to "3 days in advance", which may need review / tuning.

  • If needed, you could also use the Field Permissions module to set field-level permissions to edit, view and create this renewal field.

  • Instead of just sending an eMail (as in the Rules Component), you could replace that by a more advanced option using the Message module (which has great integrations with the Rules module also). Here is an quote about that module (from its project page):

    ... enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Part 2 - Tracking possible responses

If you'd also use the Flag module, you could enhance the above Rules logic to also "flag" the user (to indicate that you're waiting for some kind of response to the renewal eMail. By creating a view (using the Views module), you could then simply list the flagged users for which you do not have some desired response (those are the users who didn't perform a renewal).

Happy Rules-ing!

Your Answer

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