Need changes to javascript snippet related to FacetWP

260 views Asked by At

I have a snippet of js provided to me by the developers of FacetWP plugin for Wordpress and I am having difficulty making changes to it to suit my needs.

The snippet is as follows;

    <script>
    (function($) {
        $(document).ready(function() {
            $(".select-all").click(function () {
                var available = [];
                $( '.facetwp-facet-product_categories .facetwp-checkbox' ).each( function (index, item) {
                    available.push( $(item).attr( 'data-value' ) );
                });
                FWP.facets['product_categories'] = available;
                FWP.is_reset = true; // don't parse facets
                FWP.refresh();
            });
        });
    })(jQuery);
</script>

The purpose of the above code is to 'select' all checkbox options for a given facet, in this case the 'product_categories' facet, upon click of the div with the class .select-all

I need to make 2 changes here.

Firstly I need to ONLY select 1 choice for that facet.

Secondly, I need to make additional selections from additional facets.

Can anybody suggest what I might do next? I have very little experience actually so am hoping for a working example. Many thanks.

0

There are 0 answers