Are you looking for a way to disable downloadable products in your WooCommerce store? A virtual product is a product that is not physical and will not have shipping options. A downloadable product allows a customer to download a file or files after purchase.
These products are not tangible and customers can access them via a download or link.
If you are selling physical products, you may want to disable virtual or downloadable products. However, WooCommerce does not have a built-in solution to achieve this.
This means that you have to use custom code to disable these features.
WooCommerce Disable Downloadable Products
In this post, we will show you how to remove any unnecessary functionality that supports virtual and downloadable products.
However, you need some coding knowledge before you proceed. We recommend creating a child theme to make any changes.
This will ensure that your changes are not lost during an update.
Read on, as we will share a detailed step by step guide on how you can achieve this.
Let us look at how you can disable downloads in your WooCommerce store.
Steps to Remove Virtual and Downloadable Products in Your WooCommerce Store
First, we need to remove any unnecessary functionality from the admin side. This means that we have to remove the checkboxes Virtual and Downloadable on the product data meta box.
We have to remove the downloadable and virtual dropdown options from the product type filter on the products page.
Here are the steps you need to follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function that will remove virtual and downloadable checkboxes from the product data metabox.
- Add the following code to the PHP file:
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; } );
We have used the product_type_options filter hook to remove the checkboxes. Do not ignore the conditions on lines 4 and 9. This is because if you have removed them using another plugin, you will get PHP notices.
However, you will still see the separator in the product data section. To remove it, add the following CSS code in the Additional CSS section:
#woocommerce-product-data .hndle label:first-child{ border-right: 0; }
To remove the downloadable and virtual dropdown options from the product filter, add the following code in the functions.php file:
add_filter( 'woocommerce_products_admin_list_table_filters', function( $filters ) { if( isset( $filters[ 'product_type' ] ) ) { $filters[ 'product_type' ] = 'njengah_product_type_callback'; } return $filters; }); function njengah_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; }
Conclusion
By now, you should be able to easily disable downloadable products from your WooCommerce store.
We have removed all the functionality that supports downloadable products.
However, we recommend using a child theme so that your changes are not lost. If you encounter any problems, please consider contacting a qualified WordPress developer.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Hide All Products From Shop Page in WooCommerce
- How to Change WooCommerce Checkout Page Title
- How to Set Up WooCommerce Bitcoin Checkout
- WooCommerce Checkout Optimization Quick Guide
- WooCommerce Difference Between PayPal and PayPal Checkout
- How to Add Custom WooCommerce Payment Icons Checkout Page
- WooCommerce Mobile Checkout Optimization Quick Guide
- How to Add Currency to WooCommerce [Custom Currency]
- How to Create Coupon In WooCommerce
- How to Create Custom Order Received Page WooCommerce
- How to Create WooCommerce Custom Shop Page
- How to Sell Digital Products With WooCommerce