Woocommerce On Sale Custom Query

<?php

/** for an on sale product query add this to query args, use in advanced query view
 ** for layout templates - ex. https://d.pr/i/p5hxWm
 ** "post__in" => array_merge( [0], wc_get_product_ids_on_sale() )
 **/

/** this may cause facet to detect the query used in wc_get_product_ids_on_sale
 ** use this filter to prevent
 **/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 0 > $query->get( 'posts_per_page', 0 ) ) { // skips in query for -1 as post_per_page
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );