This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Hide out of stock (only in resultbox)

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)

#25808
Ernest MarcinkoErnest Marcinko
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.