Automatically scroll to the top of the WooCommerce catalog page during pagination

As there was no functional solution available online for automatically scrolling the WooCommerce catalog page to the top during Ajax pagination, I resolved the issue independently with basic JavaScript code.

It can be embedded in the head or footer via the “script” tag or linked as an external JS file, having uploaded it to the server’s scripts directory.

<script>
jQuery(function($){
$(document.body).on('click', '.page-numbers', function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
});
</script>