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

Reply To: show out of stock label in results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support show out of stock label in results Reply To: show out of stock label in results

#27471
skempenaarskempenaar
Participant

Hi ernst,

quick question about the following code. we have products in backorder that
load below the products that are instock. i would like it to function only if it is out of stock.

// —- Ajax SEARCH PRO -put to 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);
}