Managing a WooCommerce store means keeping a close eye on your product pricing, especially when running promotions or sales. However, sorting through hundreds or even thousands of products to find those with active sale prices can be a tedious task using the default WordPress admin interface.
Imagine being able to quickly filter your product list to display only items that are currently on sale, allowing you to streamline your updates and promotional strategies…
In this post, I’ll show you how to enhance your WooCommerce admin panel with a simple PHP snippet that adds a custom filter for sale status.
This solution not only saves you time but also simplifies inventory management, making it easier to plan marketing campaigns and update product details efficiently. Let’s dive into the code and get started!

PHP Snippet: Add a “Filter by sale status” Dropdown @ WooCommerce Products Admin
/**
* @snippet Filter products by sale status @ WP admin
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 9
* @community https://businessbloomer.com/club/
*/
add_action( 'restrict_manage_posts', 'bbloomer_filter_products_by_sale_status', 9999 );
function bbloomer_filter_products_by_sale_status() {
global $typenow;
if ( 'product' === $typenow ) {
$selected = isset( $_GET['sale_status'] ) ? $_GET['sale_status'] : '';
?>
<select name="sale_status">
<option value="">Filter by sale status</option>
<option value="on_sale" <?php selected( $selected, 'on_sale' ); ?>>On Sale</option>
<option value="not_on_sale" <?php selected( $selected, 'not_on_sale' ); ?>>Not on Sale</option>
</select>
<?php
}
}
add_filter( 'request', 'bbloomer_filter_products_query_by_sale_status' );
function bbloomer_filter_products_query_by_sale_status( $query_vars ) {
global $typenow;
if ( 'product' === $typenow && isset( $_GET['sale_status'] ) && '' !== $_GET['sale_status'] ) {
$sale_status = sanitize_text_field( wp_unslash( $_GET['sale_status'] ) );
if ( 'on_sale' === $sale_status ) {
$query_vars['meta_query'][] = array(
'key' => '_sale_price',
'value' => '',
'compare' => '!=',
);
} elseif ( 'not_on_sale' === $sale_status ) {
$query_vars['meta_query'][] = array(
'key' => '_sale_price',
'value' => '',
'compare' => '=',
);
}
}
return $query_vars;
}