Skip to content

woocommerce/woocommerce-subscriptions-renewal-only-coupon

Repository files navigation

IMPORTANT: This code is made available in the hope that it will be useful, but without any warranty. See the GNU General Public License included with the code for more details. Automattic or WooCommerce support services are also not available to assist with the use of this code.

WooCommerce Subscriptions - Renewal Only Coupon

Need to offer customers a discount that can only be applied to a manual renewal?

Now you can!

Renewal Only Coupons makes it possible to create WooCommerce Product or Cart coupons that can only be applied to renewal payments, not initial sign-ups, by customers via the cart.

To define the coupon codes that should be renewal only, either:

  1. Enter the coupon codes via the administration settings screen; or
  2. Use custom code to set them via the WCS_RENEWAL_ONLY_COUPON_CODES constant or wcs_renewal_only_coupon_codes' filter

Store managers can still apply Renewal Only coupons to any order or subscription. Customers can only apply them to renewal order payments.

Example error when attempting to apply a Renewal Only coupon to a new sign-up:

Usage

Step 0: Create a Coupon

To create a coupon:

  1. Go to WooCommerce > Coupons > Add Coupon
  2. Click Discount Type
  3. Click either:
    1. Recurring Product Discount or 1.Recurring Product % Discount
  4. Complete other coupon fields

Note: For best results, we recommend using either a Recurring Product Discount or Recurring Product % Discount discount type.

These discount types can be applied to subscriptions via the WooCommerce > Edit Subscription administration screen, while others, like Fixed cart or Fixed product discount types can not be applied to subscriptions.

Other discount types may also yield unexpected behaviour, for example, the Sign Up Fee discount type will not discount any part of a renewal payment, because it only discounts the sign-up fee component of an order, of which there is none on a renewal.

Option 1: Enter Coupon Codes via Subscriptions Settings

  1. Go to WooCommerce > Settings > Subscriptions
  2. Scroll to the Renewals section
  3. Click the Renewal Only Coupons text field
  4. Enter a coupon code to restrict to renewal payments only
  5. If additional coupon codes are requireed, enter a comma (, ) before each additional code

Option 2: Define Coupon Codes in Class Constant

define( 'WCS_RENEWAL_ONLY_COUPON_CODES', array( 'coupon_code_one', 'hallowoon', 'cyber_monday' )  );

Option 3: Define Coupon Codes via Filter

function eg_my_renewal_only_coupon_codes( $existing_codes ) {

	$existing_codes[] = 'my_new_code';
	$existing_codes[] = 'my_other_new_code';

	return $existing_codes;
}
add_filter( 'wcs_renewal_only_coupon_codes', 'eg_my_renewal_only_coupon_codes' );

Installation

To install:

  1. Download the latest version of the plugin here
  2. Go to Plugins > Add New > Upload administration screen on your WordPress site
  3. Select the ZIP file you just downloaded
  4. Click Install Now
  5. Click Activate

Updates

To keep the plugin up-to-date, use the GitHub Updater.

Requirements

This plugin requires:

  • PHP 5.6 or newer
  • WooCommerce 3.2.0 or newer
  • WooCommerce Subscriptions 2.4.0 or newer

Reporting Issues

If you find an problem or would like to request this plugin be extended, please open a new Issue.


About

Need to offer customers a coupon that will only discount a manual renewal payment? Now you can!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages