Update: This is now a feature that’s built directly into the Software Licensing add-on for Easy Digital Downloads. It can be accessed in Downloads > Settings > Extensions > Software Licensing. From there check the box for “Disable Discount Codes on Renewals”.

Recently I had a question about Easy Digital Downloads – Software Licensing that I hadn’t thought about before. When offering a renewal discount, how can we prevent any additional discounts from being applied to the cart? You see, depending on the discount code someone has, you could be losing money if you offer a discount to renew a license, and then a discount code is used on top of that.

So here’s the quick snippet, and what it looks like on the front end:

function kfg_check_if_is_renewal( $return ) {

	if ( EDD()->session->get( 'edd_is_renewal' ) ) {
		edd_set_error( 'edd-discount-error', __( 'This discount is not valid with renewals.', 'edd' ) );
		return false;
	}

	return $return;

}
add_filter( 'edd_is_discount_valid', 'kfg_check_if_is_renewal', 99, 1 );

Then if a customer tries to apply a discount code, with a renewal, they’ll see the following:
Screen Shot 2015-04-07 at 11.04.01 PM

If you would like a single-file plugin for this, you can get it from the EDD Library.

Posted by Chris Klosowski

Chris Klosowski is the President of Easy Digital Downloads, the easiest way to sell your digital products with WordPress. Trusted by over 50,000 smart store owners.