Reading list Switch to dark mode

    WooCommerce Add Custom Settings Tab

    Updated 15 April 2024

    WooCommerce Add Custom Settings Tab – In this blog we see how we can add custom tabs to WooCommerce settings page. When we work with WooCommerce Plugins, sometime we need to add some custom settings.

    So, it will be good as well as conceptual that we put those settings with default WooCommerce Settings.

    We can use the hook ‘woocommerce_settings_tabs’ which is provided by WooCommerce and perform action on this hook.

    add_action( 'woocommerce_settings_tabs', 'wk_add_custom_setting_tab' );

    Now, in the callback function of above action, we add the link for our custom tab –

    function wk_add_custom_setting_tab() {
       //link to custom tab
       $current_tab = ( $_GET['tab'] == 'custom' ) ? 'nav-tab-active' : '';
       echo '<a href="admin.php?page=wc-settings&amp;tab=custom" class"nav-tab '.$current_tab.'">'.__( "Custom", "domain" ).'</a>';
    }

    In above function, $current_tab variable used to display tab as active when selected. Here, we use name ‘custom’ for tab, it’s just an example, we can use any name here according to need.

    Searching for an experienced
    WordPress Company ?
    Find out More

    Now, we see how we can add content to this custom settings page. For this we used hook ‘woocommerce_settings_{tab_name}’ –

    add_action( 'woocommerce_settings_custom', 'wk_custom_tab_content' );
    Note – In woocommerce_settings_{tab_name} hook, must contain the tab name in place of {tab_name} using which we create our custom tab in first function.

    Now, we add content to the page using callback function of above action –

    function wk_custom_tab_content() {
       // content
    }

    So, in this way we can add custom tabs to WooCommerc Settings page.

    Support

    For any technical assistance, please raise a ticket or reach us by email at [email protected]. Thanks for Your Time! Have a Good Day!

    Also, discover various solutions to add more features and enhance your online store by visiting the WooCommerce plugins page. Additionally, if you require expert assistance or want to develop custom unique functionality, Hire WooCommerce Developers for your project.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home