Setup - the WooCommerce main "Shop" page with a "Filter Products By Attribute" () sidebar widget.
When I select an attribute, the page displays products accordingly (/shop/?filter_name=filter_type).
i want a check for when the page is showing a filtered list of products, i.e.
if (shop_page_is_showing_filtered())
//
elseif (is_shop())
//
Something like this is good - Show attribute description when filtering by that attribute - but it requires explicitly stating the attribute. I just want to know if my page is showing ANY attribute.
Thanks!
Setup - the WooCommerce main "Shop" page with a "Filter Products By Attribute" (https://docs.woocommerce/document/woocommerce-widgets/#section-6) sidebar widget.
When I select an attribute, the page displays products accordingly (/shop/?filter_name=filter_type).
i want a check for when the page is showing a filtered list of products, i.e.
if (shop_page_is_showing_filtered())
//
elseif (is_shop())
//
Something like this is good - Show attribute description when filtering by that attribute - but it requires explicitly stating the attribute. I just want to know if my page is showing ANY attribute.
Thanks!
Share Improve this question asked May 6, 2020 at 9:40 David FlindallDavid Flindall 111 Answer
Reset to default 0This is the answer:
function active_woocommerce_filters() {
// for older WC versions
// global $_chosen_attributes;
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
return count( $_chosen_attributes );
}
https://stackoverflow/questions/33229238/woocommerce-check-if-filtering-products