Looking further into the WooCommerce source, they fortunately, provide a filter named woocommerce_product_data_tabs
which will allow you to conditional unset tabs.
I’ve provided an example below:
add_filter('woocommerce_product_data_tabs', function($tabs) {
/**
* The available tab array keys are:
*
* general
* inventory
* shipping
* linked_product
* attribute
* variations
* advanced
*/
unset($tabs['shipping']);
return $tabs;
}, 10, 1);
You may also filter the product type drop down menu using the product_type_selector
filter and also the product type options checkboxes using the product_type_options
filter.
Example:
add_filter('product_type_selector', function($product_type) {
/**
* The available product type selection array keys are:
*
* simple
* grouped
* external
* variable
*/
unset($product_type['variable']); //as an example...
return $product_type;
}, 10, 1);
Example:
add_filter('product_type_options', function($product_options) {
/**
* The available product type options array keys are:
*
* virtual
* downloadable
*/
unset($product_options['downloadable']); //as an example...
return $product_options;
}, 10, 1);
For your reference I found these filters by first looking at the add_meta_boxes
method contained within the WC_Admin_Meta_Boxes
class within includes/admin/class-wc-admin-meta-boxes.php
;
From there you will note that they add a meta box, whose id is, woocommerce-product-data
and the callback of which is WC_Meta_Box_Product_Data::output
found within includes/admin/meta-boxes/class-wc-meta-box-product-data.php
.
It is within this output
method that the filters woocommerce_product_data_tabs
, product_type_selector
and product_type_options
exist.