How to Disable WooCommerce Action Scheduler / Subscriptions on a Staging Site

If you use the “WooCommerce Subscriptions” plugin or any other subscription plugin to charge your customers recurring, you definitely want to stop your customers from being automatically charged again — at worse multiple times during testing — from your staging site.

You also want to stop executing other scheduled events on your staging site, like sending out expiration license reminder emails. To disable these automatic events, you will need to disable the background action scheduler, which is used by WooCommerce.

You have two options to disable Subscriptions and to disable the WooCommerce action scheduler:

Disable WooCommerce Action Scheduler for Subscriptions by Using a Plugin

Install and activate free plugin Action Scheduler – Disable Default Runner.

Disable WooCommerce Action Scheduler for Subscriptions by using code

Add the code below into the functions.php or into a separate plugin:

function yourprefix_disable_action_scheduler() {
if ( class_exists( 'ActionScheduler' ) ) {
remove_action( 'action_scheduler_run_queue', array( ActionScheduler::runner(), 'run' ) );
}
}

add_action( 'init', 'yourprefix_disable_action_scheduler', 10 );

Note:

This plugin/code disables all events in the WooCommerce action scheduler library that are used by WooCommerce plugins, so scheduled events like recurring payments or sending out mails will be disabled for WooCommerce and all of its add-ons.

For more information, check out this article.

Updated on December 4, 2021