удалить Virtual and Downloadable
Wed Jan 05 2022 08:23:48 GMT+0000 (Coordinated Universal Time)
Saved by
@mastaklance
/**
* Remove Virtual and Downloadable Checkboxes from the Product Data Metabox
*/
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;
} );
/**
* Remove Downloadable and Virtual Dropdown Options from Product Type Filter
*/
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;
}
content_copyCOPY
Comments