Forums Forums Search & Filter Pro Getting WooCommerce result count elsewhere

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #245049

    Hi there,

    Using the filter for WooCommerce it shows the amount of products as a result (Showing 132 results).

    Is there a way to get this number of results shown and updated elsewhere? Using the hook “woocommerce_result_count” doesn’t update when the filter is updated, probably because it’s not in the search results div?

    Best,
    Dave

    Trevor
    #245073
    This reply has been marked as private.
    Anonymous
    #245141

    Hi Trevor, thanks for the quick reply. Updated our licence in the meantime.

    You pointed me in the right direction, for anyone wondering I’m using the following. Basically waiting for the sf:ajaxfinish, then copying the result count into my own span.

    	// 
    	// Woo Result Count	 
    	// 
    	// Load initial result count
    	var newCount = $('.woocommerce-result-count span.count').text()
    	$(".show-results .new-product-count").text(newCount);
    
    	// During ajax load get loading dots
    	$(document).on("sf:ajaxstart", ".searchandfilter", function(){
    	  $(".show-results .new-product-count").text('...');
    	});
    
    	// Add result count after loading finishes
    	$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
    		//console.log("S&F ajax finished");
    		var newCount = $('.woocommerce-result-count span.count').text()
    		$(".show-results .new-product-count").text(newCount);
    	});
    Trevor
    #245151

    Thanks for sharing. I will close this thread for now.

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