Unfortunately, that’s not easy to achieve.
WooCommerce gets the products on sale with an internal function called wc_get_product_ids_on_sale
, that offers no filter we can hook in to, to add the products on sale because of taxonomy rules:
function wc_get_product_ids_on_sale() {
// Load from cache.
$product_ids_on_sale = get_transient( 'wc_products_onsale' );
// Valid cache found.
if ( false !== $product_ids_on_sale ) {
return $product_ids_on_sale;
}
$data_store = WC_Data_Store::load( 'product' );
$on_sale_products = $data_store->get_on_sale_products();
$product_ids_on_sale = wp_parse_id_list( array_merge( wp_list_pluck( $on_sale_products, 'id' ), array_diff( wp_list_pluck( $on_sale_products, 'parent_id' ), array( 0 ) ) ) );
set_transient( 'wc_products_onsale', $product_ids_on_sale, DAY_IN_SECONDS * 30 );
return $product_ids_on_sale;
}
The way we solved that problem in a customer’s website we developed some time ago, was by implementing custom code and a new shortcode that gets the products on sale returned by the wc_get_product_ids_on_sale
function, and then we get the taxonomy ones with our internal function wctd_get_product_ids_on_sale
, merge them together and create a custom loop to show them all with that new shortcode.
That’s not something we will be able to do for you as this is a free plugin.