Implementing Klevu's search results page has been a manageable task so far. However, I encountered an issue where the search results page is displaying an Add to Cart button that should not be there, as confirmed by Klevu themselves. Their suggestion was to hide it using CSS, which led me to write this script:
<script>
window.addEventListener("load", () =>{
document.querySelectorAll('.kuProdAdditional').forEach(item => item.parentNode.removeChild(item));
})
</script>
Initially, this script worked flawlessly. But then, I was tasked with adding their infinite scrolling script into the head section, which was straightforward. However, now a new problem arises - the infinite scrolling feature triggers an Ajax call that loads subsequent pages along with the initial results. As a result, all results, including the original ones, display the Add to Cart button again. Essentially, I require assistance in ensuring that my script runs each time the Ajax call is completed.
The challenge lies in the fact that I lack the ability to modify the Ajax call to execute my script afterwards. Is there a method to detect when the page reloads so that I can run my script? While I am not a developer, I have been tasked with this IT-related assignment.