Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bulentsakarya/6b25f1e0e0c26f8758a63b9525c902de to your computer and use it in GitHub Desktop.
Save bulentsakarya/6b25f1e0e0c26f8758a63b9525c902de to your computer and use it in GitHub Desktop.
WooCommerce remove virtaul and downloadable checkbox
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;
}
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;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment