Last active
November 18, 2021 16:36
-
-
Save thenbrent/8851189 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Pour celles et ceux qui n’auraient pas compris, ce code se place directement dans le fichier "wcs-functions.php" à la racine du fichier de l'extension de Woocommerce Subscriptions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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