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.
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: