Forked from BronsonQuick/delete_all_woocommerce_subscriptions.php
Last active
April 12, 2017 16:03
-
-
Save tareiking/0042ddd4d550919438e3 to your computer and use it in GitHub Desktop.
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: Delete All Subscriptions | |
Plugin URI: | |
Description: Delete all of those bad boys | |
Author: | |
Author URI: | |
Version: 1.0 | |
*/ | |
function mystic_delete_all_subscriptions() { | |
$subscriptions = WC_Subscriptions::get_subscriptions( | |
array( | |
'subscriptions_per_page' => 1000, | |
) | |
); | |
foreach( $subscriptions as $subscription ) { | |
WC_Subscriptions_Manager::delete_subscription( $subscription['user_id'], $subscription['subscription_key'] ); | |
} | |
} | |
add_action( 'admin_footer', 'mystic_delete_all_subscriptions' ); | |
function mystic_force_delete_subscription( $subscription_can_be_changed, $subscription ) { | |
return true; | |
} | |
add_filter( 'woocommerce_can_subscription_be_changed_to', 'mystic_force_delete_subscription', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment