Remove Virtual and Downloadable from WooCommerce admin

In this tutorial I will show you two things – how to remove Virtual and Downloadable checkboxes from the Product data metabox and how to remove them from Product type filter on the All products page without any CSS of course.

Yesterday I began to create a WooCommerce shop for my good clients (Inst: @kalabasa) and I decided to share the entire process with you.

Before we begin, I want you to know one thing – what we are going to talk about is just post meta with meta keys _virtual and _downloadable which accept two values – yes or no.

Remove Virtual and Downloadable Checkboxes from the Product Data Metabox

I always configure /wp-admin/ area personally for any of my clients, so first of all I remove any unnecessary functionality. So for example if clients are going to sell only physical goods, they do not need the checkboxes Virtual and Downloadable which you can see on the screenshot below:

Virtual and Downloadable checkboxes are available for Simple products by default
Virtual and Downloadable checkboxes are available for Simple products only

I think it is worth mentioning, that when I configured the WooCommerce installation, I selected the option, which says that I’m going to sell only physical goods, but as you can see it doesn’t affect these checkboxes.

But product_type_options filter hook can help.

add_filter( 'product_type_options', function( $options ) {
 
	// remove "Virtual" checkbox
	if( isset( $options[ 'virtual' ] ) ) {
		unset( $options[ 'virtual' ] );
	}
 
	// remove "Downloadable" checkbox
	if( isset( $options[ 'downloadable' ] ) ) {
		unset( $options[ 'downloadable' ] );
	}
 
	return $options;
 
} );

Inserting this code to your theme functions.php file does the trick ?

How to hide both Virtual and Downloadable checkboxes from the Product data metabox

Do not ignore the conditions on lines 4 and 9, because if checkboxes are already removed in another place in code (maybe in some plugin), you will get PHP notices.

And the last small touches in case you are a perfectionist. Do you see a separator after the product type selection? Let’s remove it too.

separator removed in CSS

It can be done with a couple lines of CSS code and it is the only way:

#woocommerce-product-data .hndle label:first-child{
	border-right: 0;
}

You can insert the CSS either with the admin_head hook or directly in a CSS file which you use in admin area.

How to Remove Downloadable and Virtual Dropdown Options from Product Type Filter

If you go to All Products page, there could be some filters, one of them is by product type:

Filter by product type on All Products page

As you could notice, what we did with product_type_options before doesn’t affect this dropdown.

Luckily there is a hook too, but it is kind of tricky.

add_filter( 'woocommerce_products_admin_list_table_filters', function( $filters ) {
 
	if( isset( $filters[ 'product_type' ] ) ) {
		$filters[ 'product_type' ] = 'misha_product_type_callback';
	}
	return $filters;
 
});
 
function misha_product_type_callback(){
	$current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false;
	$output               = '<select name="product_type" id="dropdown_product_type"><option value="">Filter by product type</option>';
 
	foreach ( wc_get_product_types() as $value => $label ) {
		$output .= '<option value="' . esc_attr( $value ) . '" ';
		$output .= selected( $value, $current_product_type, false );
		$output .= '>' . esc_html( $label ) . '</option>';
	}
 
	$output .= '</select>';
	echo $output;
}

Let me explain how it works:

Product type dropdown with removed Downloadable and Virtual options

Related

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

Need some help with WooCommerce?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Leave a comment

php js HTML CSS Code