Advanced Description Field

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Advanced Description Field

This topic contains 5 replies, has 2 voices, and was last updated by

 
Keymaster
1 year, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25839

    Participant

    Hello, thanks for the great plugin.

    1) I use “_stock” in Advanced Description Field. It works, but zeros are added to the value: 50.000000 or 0.000000. How to remove zeros in value?

    2) Is it possible to use “if-then-else” in Advanced Description Field? I want show Out of Stock message, if “_stock” is 0.

    Thanks, Prokhor.

    #25840

    Hi,

    Can you please copy/paste your current advanced content field here? Thank you!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #25841

    Participant

    <p>SKU: <b>{_sku}</b> | In stock: <b>{_stock}</b>

    #25842

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #25859

    Participant

    Thank you very much, you helped me a lot, everything works! I just rated 5 stars for the plugin.

    #25863
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.