@Support-Luis The initial count on the filters are not accurate. When adding that filter or changing pagination, it adjust the count correctly. Also this is mostly seen with ‘Company’ filters, and not on others.
This is the code I have set. Can you help me fix this? Sent you the project share link in DM.
$(document).ready(function() {
// ⭐ NEST BEFORE FILTER ⭐
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
"cmsload",
() => {
window.fsAttributes.cmsnest.init();
window.fsAttributes.push([
"cmsnest",
() => {
window.fsAttributes.cmsfilter.init();
}
]);
}
]);
// ⭐ SHOW FILTER RESULT COUNT ⭐
setTimeout(function() {
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
"cmsfilter",
(filterInstances) => {
const [filterInstance] = filterInstances;
const filtersData = filterInstance.filtersData;
let resultsArray = filtersData.flatMap(element =>
element.elements.map(element => ({
filterName: element.value,
filterResults: element.resultsCount
}))
);
resultsArray.forEach((filter) => {
document.querySelectorAll("[fs-cmsfilter-field]").forEach((element) => {
if (element.textContent.trim() === filter.filterName) {
const resultsTextElement = element.nextElementSibling?.querySelector(".results-text");
if (resultsTextElement) {
resultsTextElement.textContent = filter.filterResults;
}
}
});
});
}
]);
}, 1500);