How to Disable Action Scheduler on a WooCommerce Store

I keep noticing that sometimes I publish guides just because my clients ask me to. In this tutorial, I’ll show different alternatives to Action Scheduler on your WordPress website (or, to be more specific, on your WooCommerce store) and why you may need to consider using them.

What Action Scheduler Is Used For in WooCommerce?

Before actually showing you ways to disable Action Scheduler, I want to discuss what exactly it does on your WooCommerce store.

So, when you disable it, it won’t be a surprise for you that some WooCommerce features will stop working.

For example:

  • woocommerce_cleanup_draft_orders – this hook allows to automatically clean up draft orders, daily. Draft orders are created when a customer has started a payment process (visited the checkout page) but hasn’t completed it yet, that’s why an order status is checkout-draft not pending. Of course, orders like this aren’t displayed in the order list and should be removed regularly.
  • wc-admin_import_orders – this hook, for example, refreshes order information in WooCommerce analytics, it runs for every order when an order is created or updated.
  • woocommerce_run_product_attribute_lookup_update_callback – updates the product attributes lookup database table, for example, when a product is updated.
  • wos_sync_order – if you’re using my Order Sync for WooCommerce plugin, this hook allows you to automatically sync orders between sub-stores.
  • rudr_inventory_sync – if you’re using my Inventory Sync for WooCommerce plugin, this action allows you to sync product stock between stores asynchronously right after an order is created or a product is updated in the WooCommerce admin.
  • The whole WooCommerce Subscription plugin relies on Action Scheduler, obviously.

There are more of them, but the lack of these ones can definitely affect your WooCommerce store’s correct functioning.

Why Disable Action Scheduler Anyway?

The reasons actually could be quite different.

For example, Action Scheduler has its database tables, and in case you have, let’s say, hundreds of thousands of WooCommerce orders on your store, it could start to be an issue.

Let’s take a look at the database tables first:

WooCommerce action scheduler database tables
You can take a look at these tables using phpMyAdmin or install the “Adminer” plugin.

In the screenshot below, you can understand pretty clearly what I mean:

List of scheduled actions in WooCommerce
You can find this page in WooCommerce > Status > Scheduled Actions.

Wait, but isn’t Action Scheduler supposed to be a better alternative to the standard WP Cron? Correct. But I guess in cases like this an alternative cron should be used.

Another situation – is when, on the other hand, you don’t have a huge online store, but you’re running cron jobs from your server every, let’s say, one minute and you can not rely on a standard way of running cron jobs (when someone visits a website). This rule also applies to Action Scheduler.

Turn Off the Default Queue Runner

The first thing you can find if you try to search for how to disable a WordPress Action Scheduler is a small plugin that just removes a single action: action_scheduler_run_queue.

Here it is:

add_action( 'init', function() {

	if( ! class_exists( 'ActionScheduler' ) ) {
		return; 
	}
	remove_action( 'action_scheduler_run_queue', array( ActionScheduler::runner(), 'run' ) );
 
}, 10 );

Okay, what actually happens if you add this snippet to your website?

Well, pending scheduled actions are still going to be created, but they will not run.

I mean, what is the point of doing it if you finally just end up in a situation like this:

Past-due actions in Action Scheduler in WooCommerce.

That’s why it is only the first step, after that you can go three separate ways:

Now, let’s talk about each one of these options in detail.

Prevent Creating Scheduled Actions in Action Scheduler

That’s what we need guys and luckily we can easily do it with the following filter hooks:

Hook nameDescription
pre_as_schedule_single_actionWith this filter hook, you can prevent creating a scheduled single action with the as_schedule_single_action() function.
pre_as_schedule_recurring_actionPrevents creating a scheduled recurring action with the as_schedule_recurring_action() function.
pre_as_enqueue_async_actionPrevents creating an async scheduled action with the as_enqueue_async_action() function.
pre_as_schedule_cron_actionFor scheduled actions created with the as_schedule_cron_action() function.

So in order to really disable Action Scheduler, we need to use these filter hooks. We just need to create a callback function that returns anything except null.

Examples:

add_filter( 'pre_as_schedule_single_action', '__return_false' );
add_filter( 'pre_as_schedule_recurring_action', '__return_false' );
add_filter( 'pre_as_enqueue_async_action', '__return_false' );
add_filter( 'pre_as_schedule_cron_action', '__return_false' );

Replace Action Scheduler with WP Cron

As I already said before, disabling Action Scheduler and using WP Cron instead only makes sense if you’re using an alternate cron.

And we can do it just by tapping into the filter hooks I mentioned previously. Luckily, these hooks have all the arguments we need to create the same cron job using WP Cron.

For example:

add_filter( 'pre_as_schedule_single_action', function( $return, $timestamp, $hook, $args ) {
	
	return wp_schedule_single_event( $timestamp, $hook, $args );
	
}, 25, 4 );

Or:

add_filter( 'pre_as_schedule_recurring_action', function( $timestamp, $interval_in_seconds, $hook, $args ) {
	
	if( $interval_in_seconds < 5 * HOUR_IN_SECONDS ) {
		$recurrence = 'hourly';
	} elseif( $interval_in_seconds < DAY_IN_SECONDS ) {
		$recurrence = 'twicedaily';
	} elseif( $interval_in_seconds < WEEK_IN_SECONDS ) {
		$recurrence = 'daily';
	} else {
		$recurrence = 'weekly';
	}

	return wp_schedule_event( $timestamp, $recurrence, $hook, $args );
	
}, 25, 4 );

As you can see, the last snippet is more tricky, because the wp_schedule_event() function doesn’t accept intervals in seconds, so we need to provide one of the predefined interval names for its $recurrence argument.

Using a Custom Queue Runner

Let’s say, you deactivated the standard Action Scheduler runner, but you decided not to replace it with WP Cron. Somehow you still need to get the scheduled tasks done.

As an option, you can do it with WP CLI.

Another option is to run the command ActionScheduler::runner()->run(), for example, you can just create a file in your site directory and put it there:

require_once __DIR__ . '/wp-load.php';

if( class_exists( 'ActionScheduler' ) ) {
	ActionScheduler::runner()->run();
}
Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 15 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X