Woocommerce

How To Hide/Remove Default Product Tab

In This Topic, We are going to see Hidde/Remove default Product Tab.
As in the previous article, we learn to Add Custom Currency With a Symbol In Woocommerce.

This article explains How to Remove the default Product Tab in woocommerce.
Here, is a hook for Hidden product default tabs.

Let’s see how to remove the unwanted product default tab. In this, we will see
1. Remove Product type
2. Default tab
3. Hidde SKU From inventory tab
4. Default content editor

Here, The default product tabs we are going to remove In this article. We simply put code in our function file.

Note: Please don’t add code to the parent theme’s fuction.php file. cause when you update the parent theme this file will be wiped entirely.

1. Remove Product type

Product type defines the type of product. When you add/ Edit a product there is an option for adding product type, that the which type of the product. simple, external, etc…
The default product type is simple.

If you want to remove other types of products. Then simply put the below code in your Function file.

add_filter( 'product_type_selector', 'remove_product_types' );
function remove_product_types( $types ){
    unset( $types['grouped'] );
    unset( $types['external'] );
    unset( $types['variable']);
    return $types;
}

Here,
product_type_selector: Hook for getting product types.
$types: variable(array) only that store the product types (you can use any variable instead of $types )

grouped, external, variable: Types of the product (this will be removed from product types)
unset () : remove the data.

Now edit or add a new product and you can see the other types of product types will be removed or hidden from product type.

2. Default Tab

If you want to hide/remove the woocommerce default tab. Remove/hide those tabs that you don’t use while adding or editing products.
Then there is a hook for removing/hiding tabs.

Also, you have to know about the hook priority. For this hook, you need the priority value must be 10 or higher than 10.
If the value is lower than 10 the hook will not work.

To remove other tabs of product. Then simply put the below code in your Function file.

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

Here, I Have hidden/remove the linked product tab and attribute tabs

woocommerce_product_data_tabs: Get the product data tabs
$tabs: an array that store the product tab(you can use any variable instead of $tabs)
unset(): for remove/ hide tabs
11: priority value

3. Hide SKU From inventory tab

If anyone does not want the SKU for their product. So they want to hide or remove the SKU from the product data table. for this woocommerce provide the hook for this.

Only put the below code in your Function file.

add_filter( 'wc_product_sku_enabled', '__return_false' );

Here, only you need to return true or false.
true: this shows the SKU field.
False: that does not show the SKU field

refresh, edit or add a new product, and goto inventory tab SKU field does not appear.

4. Default content editor

The content editor is the default WordPress post feature, So here, we use the WordPress hook to remove the content editor.

on the product page sometimes we added a short description field. so we don’t need the default content editor.
So, if need to hide it.

put the below code to the Fuction.php

add_action('init', 'init_remove_support',100);
function init_remove_support(){
    $post_type = 'product';
    remove_post_type_support( $post_type, 'editor');
}

Here,
init: WordPress hook
$post_type: it’s for defining the post type (product etc.. custom post type)
remove_post_type_support: WordPress hook for removing the feature from a specific post type.
editor: our field name(that we want to remove)

Now, check your product, the content editor will be removed from your product post type.

Please, review the video.

Here, the hooks are for hiding/removing tabs, editors, or fields.

Hope you guys find something use full related to woocommerce or WordPress.

Fenal Kalathiya

Junior WordPress Developer. Good skills in WordPress, PHP, HTML, CSS, and jQuery.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago