Last active
December 10, 2019 10:04
-
-
Save bulentsakarya/6b25f1e0e0c26f8758a63b9525c902de to your computer and use it in GitHub Desktop.
WooCommerce remove virtaul and downloadable checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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