I tested the goven code but it did not work for the purpose. I have executed the show all button by adding id=”original-section” to the that wraps the pagination in original main-collection.liquid then added a snippet with same code but replaced the pagination by and added a new section to the main-collection with id=”alternate-section”. Then added following script at the end of main-collection:
So when customer clicks button with id=”replace-section-button” it will shift from pagination to show all. However I now have faiced the problem that when customer opens any product from these sections and return to the collection with previous page browser button, it will show the original paginated collection.
would you have any idea what to add to the script to make it so that if customer clicks the product from the original collection it would return them to the right paginated page and vice versa if they have clicked the view all button and went to product from there and then return it would show the show all type of page?