Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Space needed inbtween words "out of stock" & "in stock" › Reply To: Space needed inbtween words "out of stock" & "in stock"
January 3, 2023 at 3:55 pm
#40707
Keymaster
I may have made a mistake in the previous code, the ID parameter was missing, please try:
add_filter('asp_results', 'asp_show_stock_status');
function asp_show_stock_status($results) {
foreach($results as $k=>&$r){
if ( $r->post_type == 'product' && class_exists('WC_Product') ) {
$p = new WC_Product( $r->id );
$r->content .= '<span class="'.$p->get_stock_status().'"></span>';
}
}
return $results;
}
This should work, as it requests the stock status from WooCommerce directly.