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)
Hi Ernets,
Thx for your response. looks like this does not work. maybe a different solution could be more fitting.
atm im using the code below to hide out of stock products from the resultbox from ajax search pro.
could it be possible that the out of stock items are not hidden but the do appear. but since they are out of stock their relevance is 0. Which results that the show on the bottom of the result box.
// —- Ajax SEARCH PRO – Hide out of stock—-
add_filter( ‘asp_pagepost_results’, ‘asp_stock_status_filter’, 1, 1 );
function asp_stock_status_filter( $pageposts ) {
foreach ($pageposts as $k=>$v) {
// Get the stock status
$stock_status = get_post_meta( $v->id, ‘_stock_status’, true);
if ( empty($stock_status) || $stock_status == “instock” )
continue;
unset($pageposts[$k]);
}
return $pageposts;
}