WooCommerce: Remove Product Input Panel Tab

I like to use WooCommerce and Id to hide the Related Products tab in the backend. I found a hook for adding tabs ( woocommerce_product_write_panel_tabs

), but I'm not sure if it is also possible to hide certain tabs with this hook.

Thanks for any help!

Product write panel tab

+3


source to share


2 answers


Adding the following to wp-admin.min.css should remove related products.



li.linked_product_options.linked_product_tab
{
    display:none !important;
}

      

+1


source


So I had the same problem. Woocommerce provides a filter (just like everything else) that can handle this. Filter "woocommerce_product_data_tabs".

function remove_linked_products($tabs){
    unset($tabs['linked_product']);
    return($tabs);
}
add_filter('woocommerce_product_data_tabs', 'remove_linked_products', 10, 1);

      

This will remove the related products tab. You can also disable other tabs using their array index. Below is a copy of the filter application from class-wc-meta-box-product-data.php.



$product_data_tabs = apply_filters( 'woocommerce_product_data_tabs', array(
    'general' => array(
        'label'  => __( 'General', 'woocommerce' ),
        'target' => 'general_product_data',
        'class'  => array( 'hide_if_grouped' ),
    ),
    'inventory' => array(
        'label'  => __( 'Inventory', 'woocommerce' ),
        'target' => 'inventory_product_data',
        'class'  => array( 'show_if_simple', 'show_if_variable', 'show_if_grouped' ),
    ),
    'shipping' => array(
        'label'  => __( 'Shipping', 'woocommerce' ),
        'target' => 'shipping_product_data',
        'class'  => array( 'hide_if_virtual', 'hide_if_grouped', 'hide_if_external' ),
    ),
    'linked_product' => array(
        'label'  => __( 'Linked Products', 'woocommerce' ),
        'target' => 'linked_product_data',
        'class'  => array(),
    ),
    'attribute' => array(
        'label'  => __( 'Attributes', 'woocommerce' ),
        'target' => 'product_attributes',
        'class'  => array(),
    ),
    'variations' => array(
        'label'  => __( 'Variations', 'woocommerce' ),
        'target' => 'variable_product_options',
        'class'  => array( 'variations_tab', 'show_if_variable' ),
    ),
    'advanced' => array(
        'label'  => __( 'Advanced', 'woocommerce' ),
        'target' => 'advanced_product_data',
        'class'  => array(),
    )
));

      

So, just replace unset ($ tabs ['linked_product'] with whatever tab you want to remove from the backend.

+5


source







All Articles