{
const queryString = new URLSearchParams(new FormData($refs.filter_form)).toString()
const params = new URLSearchParams(window.location.search)
const searchTerms = params.get('q')
let filterMedAccess = '';
if (window.customer.isLogged){
if (window.customer.isDoctor) {
let filterMedAccess = '';
} else {
filterMedAccess = 'filter.p.tag=customer&'
}
} else {
filterMedAccess = 'filter.p.tag=customer&'
}
fetch('/search/?q=' + searchTerms + '&' + filterMedAccess + queryString + '&sort_by=' + sort_by)
.then(response => response.text())
.then(data => {
let html_div = document.createElement('div');
html_div.innerHTML = data;
let html_dom = html_div.querySelector('#productSearchContainer').innerHTML;
let collectionActiveFilters = html_div.querySelector('#collectionActiveFilters').innerHTML;
let collectionProductsCount4 = html_div.querySelector('#resultsProductCount4').innerHTML;
document.querySelector('#productSearchContainer').innerHTML = html_dom;
document.querySelector('#collectionActiveFilters').innerHTML = collectionActiveFilters;
document.querySelector('#resultsProductCount4').innerHTML = collectionProductsCount4;
if (queryString){
const wrapp = html_div.querySelectorAll('.accordion__content--wrapper');
const arrId = ['product_type', 'brand', 'availability', 'tags', 'colour', 'pack_size', 'position', 'size', 'stock_option' ];
wrapp.forEach(elem => {
arrId.forEach(arr => {
if (arr == elem.id){
let htmlContentWrapper = html_div.querySelector(`#${arr}`).innerHTML;
document.querySelector(`#${arr}`).innerHTML = htmlContentWrapper;
}
})
})
if (window.customer.isLogged){
if (window.customer.isDoctor) {
history.replaceState(null, null, '?q=' + searchTerms + '&' + queryString + '&sort_by=' + sort_by);
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer&' + queryString + '&sort_by=' + sort_by);
}
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer&' + queryString + '&sort_by=' + sort_by);
}
} else {
const wrapp = html_div.querySelectorAll('.accordion__content--wrapper');
const arrId = ['product_type', 'brand', 'availability', 'tags', 'colour', 'pack_size', 'position', 'size', 'stock_option' ];
wrapp.forEach(elem => {
arrId.forEach(arr => {
if (arr == elem.id){
let htmlContentWrapper = html_div.querySelector(`#${arr}`).innerHTML;
document.querySelector(`#${arr}`).innerHTML = htmlContentWrapper;
}
})
})
if (window.customer.isLogged){
if (window.customer.isDoctor) {
history.replaceState(null, null, '?q=' + searchTerms + '&sort_by=' + sort_by);
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer' + '&sort_by=' + sort_by);
}
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer' + '&sort_by=' + sort_by);
}
}
})
.catch(error => console.error('Error:', error))
});
if ($event.target.getAttribute('type') == 'radio'){
sort = $event.detail.label
sort_by = $event.detail.sort_by
}
"
@update-filter-mobile.window="
$nextTick(() => {
const queryString = new URLSearchParams(new FormData($refs.filter_form_mobile)).toString()
const params = new URLSearchParams(window.location.search)
const searchTerms = params.get('q')
let filterMedAccess = '';
if (window.customer.isLogged){
if (window.customer.isDoctor) {
let filterMedAccess = '';
} else {
filterMedAccess = 'filter.p.tag=customer&'
}
} else {
filterMedAccess = 'filter.p.tag=customer&'
}
fetch('/search/?q=' + searchTerms + '&' + filterMedAccess + queryString + '&sort_by=' + sort_by)
.then(response => response.text())
.then(data => {
let html_div = document.createElement('div');
html_div.innerHTML = data;
let html_dom = html_div.querySelector('#productSearchContainer').innerHTML;
let collectionActiveFilters = html_div.querySelector('#collectionActiveFilters').innerHTML;
let collectionProductsCount3 = html_div.querySelector('#resultsProductCount3').innerHTML;
document.querySelector('#productSearchContainer').innerHTML = html_dom;
document.querySelector('#collectionActiveFilters').innerHTML = collectionActiveFilters;
document.querySelector('#resultsProductCount3').innerHTML = collectionProductsCount3;
if (queryString){
const wrapp = html_div.querySelectorAll('.accordion__content-mobile--wrapper');
const arrId = ['product_type_mobile', 'brand_mobile', 'availability_mobile', 'tags_mobile', 'colour_mobile', 'pack_size_mobile', 'position_mobile', 'size_mobile', 'stock_option_mobile' ];
wrapp.forEach(elem => {
arrId.forEach(arr => {
if (arr == elem.id){
let selectedFilters = html_div.querySelector(`#${arr}`).innerHTML;
document.querySelector(`#${arr}`).innerHTML = selectedFilters;
}
})
})
if (window.customer.isLogged){
if (window.customer.isDoctor) {
history.replaceState(null, null, '?q=' + searchTerms + '&' + queryString + '&sort_by=' + sort_by);
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer&' + queryString + '&sort_by=' + sort_by);
}
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer&' + queryString + '&sort_by=' + sort_by);
}
} else {
const wrapp = html_div.querySelectorAll('.accordion__content-mobile--wrapper');
const arrId = ['product_type_mobile', 'brand_mobile', 'availability_mobile', 'tags_mobile', 'colour_mobile', 'pack_size_mobile', 'position_mobile', 'size_mobile', 'stock_option_mobile' ];
wrapp.forEach(elem => {
arrId.forEach(arr => {
if (arr == elem.id){
let selectedFilters = html_div.querySelector(`#${arr}`).innerHTML;
document.querySelector(`#${arr}`).innerHTML = selectedFilters;
}
})
})
if (window.customer.isLogged){
if (window.customer.isDoctor) {
history.replaceState(null, null, '?q=' + searchTerms + '&sort_by=' + sort_by);
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer' + '&sort_by=' + sort_by);
}
} else {
history.replaceState(null, null, '?q=' + searchTerms + '&filter.p.tag=customer' + '&sort_by=' + sort_by);
}
}
})
.catch(error => console.error('Error:', error))
});
if ($event.target.getAttribute('type') == 'radio'){
sort = $event.detail.label
sort_by = $event.detail.sort_by
}
"
>
0 of 0 Products
Sort:
0 of 0 Products