Use the script to include narrow functionality for the search results and drop-down by a tag
const RESTRICTION_TAG = 'restricted'; // restricted
if (!CUSTOMER_LOGGED_IN) {
window.addEventListener('DOMContentLoaded', (event) => {
const encodedAttributes = encodeURI('[["Tag","' + RESTRICTION_TAG + '"]]');
document.querySelectorAll('a[href*="/collections/"]').forEach(function(e){
const href = e.getAttribute('href');
e.setAttribute('href', href + '/?narrow=' + encodedAttributes);
});
});
}
var __isp_options = __isp_options || {};
if (!CUSTOMER_LOGGED_IN) {
console.log('NOT LOGGED IN');
__isp_options.dropdown_narrow_by = [["Tag", RESTRICTION_TAG]];
__isp_options.isp_serp_ajax_header_narrow_facets = [["Tag", RESTRICTION_TAG ]];
__isp_options.isp_pre_serp_callback = function(isp_data){
console.log(isp_data);
}
window.addEventListener("load", function() {
$('form[action*=search]').on("submit", function() {
//on homepage / collection (default) do:
var hidden_input = $('<input class="isp_narrow_search" type="hidden" name="narrow">');
hidden_input.val('[["Tag","' + RESTRICTION_TAG + '"]]');
$('form[action*=search]').append(hidden_input);
//on Serp page / collections (ISP) do:
__isp_options.isp_serp_ajax_header_narrow_facets = [["Tag", RESTRICTION_TAG ]];
});
});
}