This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join our live AMA on the Future of Page Builders with Brizy's CEO! Register Now →

How To Add Custom Action Tools in WooCommerce

Updated on January 4, 2022

2 Min Read
Add-Custom-Action-Tools-in-WooCommerce

WooCommerce offers a list of useful default tools (accessed by going to System Status > Tools). However, it is easy to your own custom buttons to this area. This way, you could add custom functionality to your WooCommerce store.

Custom Action Tools in WooCommerce

In this tutorial, I will create a plugin that would add a custom action in the WooCommerce tools. In order to add the button, I will start by the hook woocommerce_debug_tools. Next, when  I will create a callback function (called debug_button_action()) that would be triggered when the users click the button. I will place the custom code for the custom action in this function.

Here is the code for the plugin:

<?php
/*
Plugin Name: Cloudways Tools For Custom Button
Description: A simple plugin to add a custom button to WooCommerce tools
Version: 1.0
 */
$GLOBALS['CW_Tools_For_Custom_Button'] = new CW_Tools_For_Custom_Button();
class CW_Tools_For_Custom_Button {

    function __construct() {
        add_filter( 'woocommerce_debug_tools', array( $this,'cw_button_for_debug' ) );
    }
    function cw_button_for_debug( $old ) {
        $new = array(
            'cw_custom_button' => array(
                'name'		=> __( 'Tools Button', '' ),
                'button'	=> __( 'Hit The Button', '' ),
                'desc'		=> __( 'Cloudways Tools For Custom Button', '' ),
                'callback'	=> array( $this, 'cw_button_for_debug_action' ),
            ),
        );
        $tools = array_merge( $old, $new );
        return $tools;
    }
    function cw_button_for_debug_action() {
        echo '<div class="updated"><p>' . __( 'Cloudways custom action triggered', '' ) . '</p></div>';
    }
}

Install & Activate the Plugin

The next step is the activation of the plugin. The first step is the creation of a folder in the Plugin folder. Name the folder “Cloudways Tools” and then create a file inside this folder with the name “CW_tools_for_custom_button.php”.

Next, go to the WordPress Admin Panel and you will see a new entry with the name Cloudways Tools For Custom Button.

Custom Tool Plugin

Once you have activated the plugin, go to WooCommerce > System  Status

Tool Button

Once you have hit the button, you will see the following:

Triggered Action

Conclusion

In this short tutorial, I discussed how you could easily create and activate a simple plugin that would create a custom order action to the WooCommerce System Status > Tools. You could easily extend this plugin to add your own custom action to the WooCommerce store. Let me know if you need help with the code. Just leave a comment and I will get back to you.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now