0

WooCommerce settings are located at wp-admin/admin.php?page=wc-settings and each of the Tabs for its settings is a continuation of the URL query string (ex: wp-admin/admin.php?page=wc-settings&tab=products for Products).

I know how to use the woocommerce_settings_tabs_array hook to manipulate the tab itself, but these Tabs also have sub links called "Sections."

For example, Products has General, Inventory, Downloadable Products and Product Vendors for me since I have a premium plugin.

How do I remove these sections from underneath the tab? Specifically, I want to remove the Product Vendors link that that premium extension added.

2 Answers 2

2

WooCommerce settings with product tab

To change this "sub navigation" you could use the WooCommerce filter "woocommerce_get_sections_products".

The following example code will remove the sub navigation point "inventory":

function change_navi_function($sections)
{
    // remove sub navigation point "inventory"
    unset($sections['inventory']);

    return $sections;
}

add_filter('woocommerce_get_sections_products', 'change_navi_function');

WooCommerce settings with product tab without the subnavigation point inventory

What you have to do now is either to hook your "change_navi_function" function after the function from the premium plugin and then remove the "Product Vendors" from the "$sections" array. Or you unhook the function from the premium plugin which use the "woocommerce_get_sections_products" filter.

-1

you can find the file in ~/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php

foreach ( $tabs as $slug => $label ) {
    echo '<a href="' . esc_html( admin_url( 'admin.php?page=wc-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
}

and edit html-admin-settings.php add code

foreach ( $tabs as $slug => $label ) {
    if( $slug != "Product"){
        echo '<a href="' . esc_html( admin_url( 'admin.php?page=wc-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
    }   
}
3
  • You should never change a core file, also plugin core. What is after an update of the plugin?
    – bueltge
    Commented Sep 25, 2019 at 10:37
  • I can't update this website ,because it is unimaginable.
    – Eli King
    Commented Sep 26, 2019 at 2:21
  • @user141080 's solution can't work
    – Eli King
    Commented Sep 26, 2019 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.