Is there a conditional function or another solution to check if the products are currently filtered?
Something like this would be great:
if( is_filtered() ) echo 'Filters active';
Amazing would be if the function returns the number of active filters (or a array) or false.
You can check using
global $_chosen_attributes;
WooCommerce "Layered Nav Filters" only displayed if filters is active. you can check the code "includes/widgets/class-wc-widget-layered-nav-filters.php":Thanks to David Chandra Purnama who pushed me in the right direction here's a very simple function to use:
The function returns the number of active filters so it can be used like this:
EDIT:
As Artur Czyżewski pointed out the
$_chosen_attributes
global variable is not available in his installation. This is most likely due to changes to WooCommerce and probably affect all newer versions, so i've updated theactive_woocommerce_filters
function above.