skip to Main Content
+30-6944453971 info [a] selidamou.gr

Clean filter for the woocommerce brands pro plugin

Having tried too many plugins for a proper brands plugin that actually does its job. I finally ended up with the woocommerce brands pro. Everything good. Does its job. Except one small problem. Like woocommerce layered nav, the similar woocommerce brand layered nav does not have a clear filters button-link or anything! Didnt contact support to be honest. My client had a hard time finding the purchase code and it got me a bit delayed getting some officeial support.

So after spending some considerable amount on google, I found out a way to overcome that and find a solution to my problem. If you observe, the filtering uses the address field of your browser. If you mannualy delete the ?filtering field, then its gone.  So what i try to do is first add a hook in the widget i want so i can call my function from anywhere in the theme and then i add my function to the themes functions file.
To repeat. This is not official. Its just a small hack and it does ALTER THE CODE of the plugin, so it WILL be lost on a update that you will do..

 

We will add one line. A hook that is, inside the plugins code. The addition goes in the file  class-wc-widget-brand-nav.php

on line 334 (woocommerce brands pro by proword version 4.3.1)

do_action( ‘vas_woocommerce_layered_nav_bottom’ );

I’ll give you a screenshot as well to see where the code exactly goes.

After that you go in the themes functions file and add the following lines

add_action('vas_woocommerce_layered_nav_bottom', 'add_clear_filters');
function add_clear_filters() {
 $filterreset = $_SERVER['REQUEST_URI'];
 if ( strpos($filterreset,'?filtering') !== false ) {
 $filterreset = strtok($filterreset, '?');
 echo '<div class="clear-filters-container"><a id="woo-clear-filters" href="'.$filterreset.'">X &nbsp; Remove filter</a></div>';
 }
}

What the above code does is to call the hook that we got in the brands pro layered nav widget file and first check if there is any filtering done. In the case the filtering is active then show to the user the remove filters link.

Back To Top
×Close search
Search