How to Create a Custom System Status Tool

Quite recently I was guess what – working on my Simple Inventory Sync plugin and I was needed some kind of functionality that allows to push the actual product stock quantity to all substores via WooCommerce REST API (and that’s why it should be doing it in the background).

And I think that to create a tool in WooCommerce > Status > Tools is the most seemless way to implement that functionality.

For me it is still doesn’t make any sense why plugin developers overload WordPress admin menu with tons of settings when you can use build-in UI for that. Well, this is another story.

Here is a status tool we are going to create in this tutorial:

Create a custom system status tool in WooCommerce

Well, guys, creating your own custom system status tool in WooCommerce is as easy as to use woocommerce_debug_tools filter hook (and code snippet below).

add_filter( 'woocommerce_debug_tools', 'rudr_status_tool' );

function rudr_status_tool( $tools ) {

	$new_tool = array( 
		'rudrtool' => array(
			'name'     => 'Tool by Misha',
			'button'   => 'Start doing something',
			'desc'     => 'This tool allows to do something',
			'callback' => 'rudr_do_something',
			'disabled' => false,
		),
	);

	$tools = array_slice( $tools, 0, 2, true ) + $new_tool + array_slice( $tools, 2, NULL, true );

	return $tools;

}

// callback
function rudr_do_something() {

	return 'Something has been done!';

}

Let’s desonstruct the above code just a little bit:

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 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