Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple plugin to disable certain core actions from being carried out on a subscription with the WooCommerce Subscriptions plugin. For example, prevent a subscription from being changed to a new payment method.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Disallow Subscription Actions
* Plugin URI: https://docs.woothemes.com/document/subscriptions/faq/#section-63
* Description: Prevent core actions from being carried out on a subscription with the WooCommerce Subscriptions plugin.
* Author: Brent Shepherd
* Author URI:
* Version: 2.0
*/
/**
* Do not allow any subscriptions to be changed to a new payment method.
*/
add_filter( 'woocommerce_can_subscription_be_updated_to_new-payment-method', '__return_false', 100 );
/**
* Do not allow a customer to resubscribe to an expired or cancelled subscription.
*/
//add_filter( 'wcs_can_user_resubscribe_to_subscription', '__return_false', 100 );
/**
* Do not allow any subscriptions to switched to a different subscription, regardless of settings (more: http://docs.woothemes.com/document/subscriptions/switching-guide/).
*/
//add_filter( 'woocommerce_subscriptions_can_item_be_switched_by_user', '__return_false', 100 );
// OR
//add_filter( 'woocommerce_subscriptions_can_item_be_switched', '__return_false', 100 );
/**
* Subscriptions Status Changes
**/
/**
* Do not allow any subscriptions to be activated or reactivated (not a good idea).
*/
//add_filter( 'woocommerce_can_subscription_be_updated_to_active', '__return_false', 100 );
/**
* Do not allow any subscription to be cancelled, either by the store manager or customer (not a good idea).
*/
//add_filter( 'woocommerce_can_subscription_be_updated_to_cancelled', '__return_false', 100 );
/**
* Do not allow any subscription to be suspended, either by the store manager or customer (not a good idea).
*/
//add_filter( 'woocommerce_can_subscription_be_updated_to_on-hold', '__return_false', 100 );
@edurigam

This comment has been minimized.

Show comment
Hide comment
@edurigam

edurigam Mar 12, 2018

Is it possible to adapt this to disallow variable product subscriptions to be switched to a specific different variation?

Or to disallow variable product subscriptions downgrades only?

Thanks

edurigam commented Mar 12, 2018

Is it possible to adapt this to disallow variable product subscriptions to be switched to a specific different variation?

Or to disallow variable product subscriptions downgrades only?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment