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"
Hi,
You are welcome.
The plugin only requests the “_stock_status” custom field and prints it’s value as instructed – the value is either “instock” or “outofstock”. Maybe on external products this is not controlled or is automatically set to “instock” by WooCommerce. I have not found any information regarding that in their documentation.
I can only assume that the stock status is later changed during the execution via a hook, but not the actual value in the database.
There is one more thing you can try, this custom code:
1. Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
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->content .= '<span class="'.$p->get_stock_status().'"></span>';
}
}
return $results;
}
2. Remove this <span class="{_stock_status}"></span> from the advasced content fields, the custom code will handle it.
3. Keep the custom CSS suggested.