PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]
Botoscope is currently in early access

Support Forum

You need to log-in to create request (topic) to the support

Text search: How to ignore active filters and search entire store?

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello team,

I'm using HUSKY Products Filter Pro on a WooCommerce store. I need the text search field  to always search across the entire store, regardless of any other active filters (category, attributes, price, etc.).

Currently, when a customer has filters applied and then uses the text search box, the search is constrained to the filtered results.

The expected behavior is that a text search should always reset the other filters and search the whole catalog.

My questions:
1. Is there a built-in setting or shortcode attribute to achieve this behavior?
2. If not, is there a hook or filter (e.g. woof_get_request_data) that I can use to strip the active filters when a text search is submitted?

Thanks in advance.

Hector

Hello Hector

There is no built-in setting for this behavior, but it can be achieved with a small custom snippet.

The way HUSKY works on category pages, the text search runs within the current category context. To make it always search the full catalog, the cleanest solution is to intercept the text search submission on the front end and redirect to the main shop page with the search term as a parameter, bypassing the category context entirely.

Add this snippet to your theme's functions.php file:

add_action('wp_footer', function() {
    if (!is_product_category() && !is_shop()) return;
    $shop_url = esc_url(wc_get_page_permalink('shop'));
    ?>
    <script>
    jQuery(document).ready(function($) {
        function woof_text_redirect() {
            var val = $('.woof_husky_txt-input').val().trim();
            if (val.length < 1) return;
            window.location.href = '<?php echo $shop_url; ?>'
                + '?swoof=1&woof_text=' + encodeURIComponent(val);
        }
        $(document).on('click', '.woof_text_search_go', function(e) {
            e.stopImmediatePropagation();
            woof_text_redirect();
        });
        $(document).on('keydown', '.woof_husky_txt-input', function(e) {
            if (e.which === 13) {
                e.stopImmediatePropagation();
                woof_text_redirect();
            }
        });
    });
    </script>
    <?php
});

What this does: when a customer clicks the search button or presses Enter in the text field, it redirects to your main shop page with the search term applied across the full catalog, regardless of what category or filters were previously active.

Regarding your question about woof_get_request_data, if you want the autocomplete dropdown (the Ajax suggestions that appear as you type) to also ignore active filters and search the full catalog, add this to functions.php:

add_filter('woof_get_request_data', function($request) {
    if (
        wp_doing_ajax() AND
        isset($_REQUEST['action']) AND
        $_REQUEST['action'] === 'woof_text_search' AND
        !empty($request['woof_text'])
    ) {
        // Strip everything except the text search term
        $request = ['woof_text' => $request['woof_text']];
        // Also kill the category context passed separately
        unset($_GET['really_curr_tax']);
    }
    return $request;
}, 20);

This intercepts only the text search Ajax request and strips all active filters and the category context from it, so the suggestions always come from the full catalog. The priority 20 is important because HUSKY registers its own hook on the same filter at priority 10, so ours needs to run after.