How to Disable Downloadable Products WooCommerce

WooCommerce Disable Downloadable ProductsAre 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.virtual downloadable

We have to remove the downloadable and virtual dropdown options from the product type filter on the products page.product page

Here are the steps you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. 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.
  3. 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;

} );

 

  1. This is the outcome:remove checkbox

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;

}

This is the outcome:remove drop down

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.

Similar Articles