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:
If you would like a single-file plugin for this, you can get it from the EDD Library.