Last active
June 20, 2022 15:14
-
-
Save djrmom/b56c08656e9578fd99dc29c1655bab22 to your computer and use it in GitHub Desktop.
facetwp reset facets on search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** reset a facet (facet 2) on submission of different facet (facet 1) | |
** change 'search' to name of facet 1 | |
** change 'product_categories' to the name of the facet 2 | |
**/ | |
add_action( 'wp_footer', function() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-refresh', function() { | |
if ( 'undefined' !== typeof FWP.facets['search'] && FWP.facets['search'].length < 1 ) { | |
FWP.facets['product_categories'] = []; | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment