Disable Virtual and Downloadable Products

Sometimes clients are looking for a solution to completely disable downloadable (and virtual) products functionality. And in this tutorial I will show you how exactly you can do it and even without using WordPress plugins.

There are 4 steps:

  1. Remove downloads endpoint.
  2. Remove checkboxes from the admin edit product pages.
  3. Remove dropdown options from Product Type Filter.
  4. Remove downloadable product permissions meta box from edit order pages.

I will describe every step in details.

1. Remove Download Endpoint

First things first, let’s remove “Downloads” page from customer accounts.

Downloads page in WooCommerce my account

I have an additional tutorial about that by the way, but there is no needs to read it now, just go to WooCommerce Settings, Advanced tab and then remove “Downloads” endpoint.

remove downloads endpoint in WooCommerce settings

That’s it! “Downloads” tab won’t be available in My Account area anymore.

2. Remove Virtual and Downloadable Checkboxes from the Product Data Metabox

I always configure /wp-admin/ area personally for all of my clients, so first of all I remove any unnecessary functionality. For example if clients are going to sell only physical goods, they do not need the checkboxes Virtual and Downloadable that 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 3 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.

3. 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:

product type filter on WooCommerce all products page

As you may 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.

<?php
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_type = isset( $_REQUEST[ 'product_type' ] ) ? wc_clean( wp_unslash( $_REQUEST[ 'product_type' ] ) ) : false;
	?>
		<select name="product_type" id="dropdown_product_type">
			<option value="">Filter by product type</option>
			<?php foreach( wc_get_product_types() as $value => $label ) : ?>
				<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $value, $current_type ) ?>>
					<?php echo esc_html( $label ) ?>
				</option>
			<?php endforeach; ?>
		</select>
	<?php
}

Let me explain how it works:

Remove downloadable and virtual products from product type filer

4. Remove Meta Box from Order

The last but not least is to remove metabox “Downloadable product permissions” from edit order pages.

This one:

downloadable product permissions meta box

This is how to remove it:

add_action( 'add_meta_boxes', 'misha_remove_downloads_meta_box', 999 );

function misha_remove_downloads_meta_box(){
	remove_meta_box( 'woocommerce-order-downloads', 'shop_order', 'normal' );
}
Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X