Skip to content

Instantly share code, notes, and snippets.

@philcon93
Created September 8, 2017 00:03
Show Gist options
  • Save philcon93/7095ddb8adf979e3aca0a7a2ef50e53e to your computer and use it in GitHub Desktop.
Save philcon93/7095ddb8adf979e3aca0a7a2ef50e53e to your computer and use it in GitHub Desktop.
Neto filters

Neto Filters

(function($) {
$.extend({
buildFilter: function() {
/*
The ?rf= URL parameter determines which filters are active. List the filter types in any order.
Brand/content = cn; price = pr; variation/specifics = va;
So, if we are filtering by price and brand, ?rf=prcn or ?rf=cnpr
A second lot of URL parameters determine what each filter should filter by.
i.e., to filter by category 112, and variation 3, your parameters might look like this: ?rf=cnva&va=3&cn=112
This function generates that URL from the inputs in the sidebar.
*/
var filter = '?rf=';
var pricefilter = '';
var brandfilter = '';
var variationfilter = '';
if (document.getElementById('brandFilter').value){
filter += 'cn';
var brandfilter = '&cn=' + document.getElementById('brandFilter').value;
}
if (document.getElementById('variation').value){
filter += 'va';
var variationfilter = '&va=' + document.getElementById('variation').value;
}
if (document.getElementById('filter-price').value){
filter += 'pr';
var pricefilter = '&pr=' + document.getElementById('filter-price').value;
}
filter += variationfilter + pricefilter + brandfilter;
if (document.getElementById('nIncludeCategory').checked == true){
document.location.href = encodeURI(filter);
} else {
document.location.href = '../' + encodeURI(filter);
}
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment