Remove and Change Vendor Product Editor Tabs for Variable Products

This snippet was first given to me in order to hide the Inventory tab if the product type was set to Variable. The Woocommerce default lets you force managing inventory at the product level. Apparently, this proved way too confusing for a significant number of my vendors, so I just remove the tab with this code snippet. There are very few scenarios for my niche that you’d need to manage inventory at the product level, which might not be the case for everyone.

Next, I used this to fine tune when certain tabs would be displayed in the second section. You can choose exactly which classes apply.

As always, this is either added to your Child Theme’s functions.php file, or consider using the My Custom Functions Pro plugin to manage and organize all your snippets.

add_filter( 'wcmp_product_data_tabs', 'hide_tabs');

// Remove the main inventory tab if the product is variable. This targets the class in the array directly and unsets it.
function hide_tabs($hide_tabs_variable){
    return $hide_tabs_variable;

add_filter( 'wcmp_product_data_tabs', 'hide_tabs_ship_variable');

// Alternate method that works if you want to get very specific... redo the array to set all the classes.
function hide_tabs_ship_variable($tabs){
	$tabs['shipping']['class'] = array( 'show_if_simple', 'hide_if_variable', 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' );
  	$tabs['attribute']['class'] = array( 'hide_if_simple', 'show_if_variable', 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' );
    $tabs['general']['class'] = array( 'show_if_simple', 'show_if_variable', 'show_if_virtual', 'hide_if_grouped', 'hide_if_external' );
    return $tabs;

Tested and working on Woocommerce 4.6.1, WCMp 3.5.10

Is this no longer relevant or not working? Please let us know in the comments!

Comments on this post

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