问题
In WooCommerce version 3.0+, I would like to remove All shipping Countries filter on Woocommerce order panel.
How to do that? any ideas ?
Thanks
回答1:
This selectors you want to remove are custom and certainly added by a third party plugin.
You can try this to hide the drop-down selector field with a custom function hooked in admin_head
action hook. You will need to replace the CSS ID #my_selector_id
by the ID or the class of the selector you want to hide (using your browser code inspector to find the right selector)
add_action( 'admin_head', 'adding_custom_css_in_admin_head', 999 );
function adding_custom_css_in_admin_head() {
?>
<style type="text/css">
body.post-type-shop_order select#my_selector_id {
display: none !important;
}
</style>
<?php
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested, and it should work with your drop-down selector field.
回答2:
I removed by using css i added this function in function.php
add_action('admin_head', 'hidey_admin_head');
function hidey_admin_head() {
echo '<style type="text/css">';
echo 'select[name=_customer_shipping_country] {display: none;}';
echo '</style>';
}
回答3:
The selected answer is not the best solution as the filters are still created, they are just hidden. Instead, you should hook the correct filter and prevent WooCommerce plugin to create the select boxes:
add_filter( 'woocommerce_products_admin_list_table_filters', 'my_woocommerce_products_admin_list_table_filters' );
function my_woocommerce_products_admin_list_table_filters( $filters ) {
// to remove the category filter
if( isset( $filters['product_category'] ) ) {
unset( $filters['product_category'] );
}
// to remove the product type filter
if( isset( $filters['product_type'] ) ) {
unset( $filters['product_type'] );
}
// to remove the stock filter
if( isset( $filters['stock_status'] ) ) {
unset( $filters['stock_status'] );
}
return $filters;
}
回答4:
You can try this to hide the drop-down selector field with a custom function hooked in admin_head action hook. You will need to replace the CSS ID #my_selector_id
by the ID or the class of the selector you want to hide (using your browser code inspector to find the right selector), You can view if the property is working as expected by going to developer's tool of the browser and selecting each elements.
来源:https://stackoverflow.com/questions/43801475/remove-a-dropdown-select-field-filter-in-woocommerce-admin-orders-list