Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Hide out of stock (only in resultbox) › Reply To: Hide out of stock (only in resultbox)
February 13, 2020 at 4:48 pm
#25808
Keymaster
Hi,
That works, but I actually may have figured out something to push them to the bottom:
add_filter('asp_results', 'asp_order_out_of_scock', 10, 1);
function asp_order_out_of_scock($results) {
$first = array();
$last = array();
foreach ( $results as $k => &$r ) {
if ( get_post_meta($r->id, '_stock_status', true) == 'instock' ) {
$first[] = $r;
} else {
$last[] = $r;
}
}
return array_merge($first, $last);
}
I have not tested this, so please be careful.