How to Add a Custom Status Tools Action in WooCommerce blog image

As a plugin or theme developer that works with WooCommerce you may have some actions that need to be ran incidentally. Maybe on an schedule, or allowing this action to be triggered manually. The latter is what I’m focussing on in this post today. WooCommerce has a place for adding such actions in the WooCommerce > Settings > Tools area.

WooCommerce > Status > Tools default page. You'll be adding your own custom action to this soon enough.

Adding a Tools Action

As you can see WooCommerce already has a good list of actions that can be taken here. Adding a additional action is quite simple, but do be aware that you’re quite limited to having a name, description and button text that can be configured.

The following code snippets adds a new action called “My custom action name”.

The ‘callback’ parameter is the function name that should be called after pressing the button on the Status > Tools page. In this case it simply logs a ‘Hello World’ to the PHP error log. This is where you can add your own code that needs to be executed.

It should look something like this:

Showing the newly added Status > Tools action

Jeroen Sormani

I'm a professional WordPress plugin developer on a mission to create the best plugins for my clients. I'm specialised in developing general WordPress, WooCommerce and Easy Digital Downloads plugins.

Interested in talking about a WordPress project? Get in touch!

Follow me on Twitter

Leave a Reply