0

Setup - the WooCommerce main "Shop" page with a "Filter Products By Attribute" (https://docs.woocommerce.com/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!

0

This 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.com/questions/33229238/woocommerce-check-if-filtering-products

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.