Archived topic
Clear all selected options for woocommerce filters
3 replies · Started by roadlink on November 21, 2021
Hi,
When customer select some filters they have to click all to remove them. https://prnt.sc/20e28es
Is there any way to add clear all of my selections?
Hi there,
Unfortunately this is something you will need to check with WooCommerce' support team as the filter is coming from the plugin itself.
Thanks for your understanding.
Hi Leo,
thanks it is fair.
Actually i find a way to make it.
Add below code to funtions.php and add [cleanthemall] shortcode under your selections widget.
Maybe some others may need it.
I just couldn't solve extra line here. https://prnt.sc/20e69c7
If someone give me suggestion we can make the code perfect :)
/*Clean active filters, Use this as a shortcode [cleanthemall]*/
add_shortcode( 'cleanthemall', 'cleanthemall' );
function cleanthemall() {
$filterreset = $_SERVER['REQUEST_URI'];
if ( strpos($filterreset,'?filter_') !== false | strpos($filterreset,'?min_price') !== false | strpos($filterreset,'?max_price')) {
$filterreset = strtok($filterreset, '?');
echo '<div class="clear-filters-container"><a id="woo-clear-filters" href="'.$filterreset.'">Clean All Filters</a></div>';
}
}
I would recommend asking the question like this in a general WordPress forum to get more audience:
https://wordpress.stackexchange.com/
Thanks for your understanding :)