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

Reply To: Space needed inbtween words "out of stock" & "in stock"

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"

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