PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

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

Assistance Needed: Quick Search Filter Not Applying Current Product Category Page

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 Support Team,

I am using Husky Product Filter Professional and I am specifically using the Quick Search Filter feature. The integration is completed and the filter appears correctly. However, I am facing an issue on Product Category pages.

When I place the filter shortcode on a Product Category page, the filter displays, but it does not auto-select or apply the current category that the user is viewing.

Example:
If the user is on:
https://example.com/product-category/shoes/
I want the Quick Search Filter to automatically detect and apply the Shoes category so that the results shown are only from that category.

Goal:

  • The Quick Search Filter should automatically recognize and apply the current product category on category archive pages, or otherwise ensure only products from that category are displayed.

Is there any option, setting, or code snippet available to enable this behavior?

Thank you for your assistance.

Kind regards,
[chetan patel]

Hello Chetan

By logic filter should show only sub-categories of the current category and its works in this way, since this implies that the user will filter products in this category, and therefore all categories above the current category will not be shown.

Text Filter - please using private area of this ticket give me please exact link what you mean. Look here please: https://demo.products-filter.com/product-category/clothing/wooman/capri/ - enter any word from found product into text search on the header - it will find any of them, but if will be entered word 'zipper', this is part of title from man category - nothing will be found, so automatically it listen current category as is

Quicke search filter - is using javasript, and take products from json to give answer very quickly, so it can not listen php current environment

https://share.pluginus.net/image/i20230222134241.png
https://share.pluginus.net/image/i20230222134615.png
https://share.pluginus.net/image/i20230222134511.png

I want to use the Quick Search Filter  and product category  page, but I don't get results

I am using the Quick Search feature, and on product category pages, it is not returning any products from the current category. The search is not detecting or showing the products of the category that the user is currently viewing.

Additionally, I am not using the AJAX filter.

Could you please guide me on how to make the Quick Search display products from the current product category?

Hello Chetan

Undertood your logic, but Quick Search is working with json data using javascript, and its blind to categories page. Logic about its extension is place shortcode to separate page use filtering. If you want to use it by your idea - code need customization to listen current category

Could you please guide us on the recommended approach to implement this customization?

Specifically:

Which filter/hook or script file should we extend to pass the current category ID into the JSON request?

Do you have an existing method or sample snippet to make the search respect the active category context?

Any documentation or example would be very helpful.

Hello Chetan

Look, when in admin panel clicked button to take all the data - all products are placed into json file. JS logivv of filtering is placed in this file wp-content\plugins\woocommerce-products-filter\ext\quick_search\js\quick_search.js - you need to customize function woof_do_quick_search_search(type, page, per_page). For data manipulating there applied library alasql, which allows use MySQL syntax inside javascript. You need to understand using console.log what type of data used by filtering and in result MySQL query apply caurrent category as selected one.

To understand what category page is current you can place next code into file functions.php of the current wp theme:

add_action('woocommerce_before_main_content', function() {
if (is_product_category()) {
$term = get_queried_object();

if ($term && isset($term->term_id)) {
$category_id = (int) $term->term_id;
$category_slug = esc_js($term->slug);

echo"<script>
var currentCategoryId = {$category_id};
var currentCategorySlug = '{$category_slug}';
</script>";
}
}
});

This is basically a short description of where to look and what to do. But you should be a developer to solve this problem