How to alter or disable the EDD renewal discount if the license key expired

It’s common practice (at least at the moment) in the WordPress world to offer a discount when someone renews their license key for your plugin.  This is to entice them to keep the license key active, and to lessen the chance of scaring them away when you say that support and updates are only for one year.

But I don’t want to give the same full discount forever, if they let their license expire then decide to renew weeks or months down the road.  By creating a time limit on the discount it forces the decision to be made and renew.

I assumed Easy Digital Downloads would only give the discount if the license was still active.  So I created a discount code for after the license expires, and added it to the URL in the email sent out after the license has expired.  But this caused a 20% discount code in addition to the 30% license renewal discount, for a total of 50%.

Oops.

Here’s the right way to give a discount on license renewal, but either lower the discount or remove it altogether after the license has expired.

Set the renewal discount

Under Downloads > Settings > Extensions > Software Licensing, you can set the global renewal discount to (say) 30%:

Or you can set the discount for each download individually:

Create a plugin to alter the discount if license key has expired

Add a new file under wp-content/plugins/ called edd-customize-renewal-discount.php with the following code:

 <?php
/*
Plugin Name: Customize Easy Digital Downloads Renewal Discount
Description: Give normal discount to renew before expiry, only 20% if license has expired
Version: 1.0
Author: Brian Hogg
Author URI: https://brianhogg.com
License: GPL2
*/
function edd_ecn_change_discount_after_license_expires( $renewal_discount, $license_id ) {
   $license = edd_software_licensing()->get_license( $license_id );
   if ( ! is_object( $license ) ) {
      // This can happen during purchase where the license ID is not yet valid
      return $renewal_discount;
   }
   if ( $license->is_expired() ) {
      $renewal_discount = 20; 
   }
   return $renewal_discount;
}
add_filter( 'edd_sl_renewal_discount_percentage', 'edd_ecn_change_discount_after_license_expires', 10, 2 );

Then, activate the plugin.

This will change the renewal discount to 20% if the license has expired, otherwise it will leave it at the default. You can change this to whatever percentage you like, and add in some additional logic if you want to have a different post-expiry discount depending on which download they purchased.

Create an email after the license has expired

If you are going to give a discount indefinitely after the license has expired, create a new email that’ll be sent when the license expires under Downloads > Settings > Extensions > Software Licensing, then Renewal Notices at the bottom.

If you alter the default “your account” page to show a nice big “Renew Now” button, just point customers to your account page with an email like this:

Subject: Your {product_name} license has expired
Hello {name},

Your {product_name} license has expired. You will no longer receive new releases of the plugin and will no longer have access to email support. If you decide to renew or upgrade at some point, you will get 20% off. It won’t expire.

To renew your license, simply click the link below and follow the instructions.

<a href="https://eventcalendarnewsletter.com/account">Renew now at 20% off</a> (click "Renew Now" after login)

Thanks!
Brian
(Creator of {product_name})

Consider Recurring Payments

All this can be avoided if you add in automatic recurring payments to your plugin.  It’s a lot less hassle for you and the customer, and gives you a more predictable revenue stream in future years.  Many plugin authors have seen renewal rates jump to 80% or more after adding in recurring payments.