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

Reply To: Advanced Description Field

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