Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Advanced Description Field › Reply To: Advanced Description Field
February 18, 2020 at 1:50 pm
#25842
Keymaster
Hi,
I assume you probably want to display the stock information whenever the stock is > 0. I have constructed a quick custom code snippet that you should try for that. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter( 'asp_results', 'asp_add_stock_count', 10, 1 );
function asp_add_stock_count($results) {
foreach ( $results as $k => &$r ) {
$stock = get_post_meta($r->id, '_stock', true);
if ( $stock > 0 ) {
$stock = intval($stock);
$r->content .= " | In stock: $stock</b>";
}
}
return $results;
}
This should also force the number value to integer, removing the extra zeros.