productpage onready() event does not always fire

Hi

I have placed code on the onready() event of Wix productpage. My aim is to use getproduct() to obtain data about the product currently displayed.
When first opening the productpage, the onready() event fires and my code is run successfully (including a console.log). It also runs if I go back to, say, the homepage and re-open the productpage. It does not seem to run, however, when already in the productpage and either of the built-in Prev/Next navigation buttons are clicked. The only way to get the code to run after pressing Prev/Next is to refresh the page?
How do I correct this please?

Thanks

For anyone else out there who is struggling with this…
Use the wix-location module which has an onChange() event. See https://www.wix.com/velo/reference/wix-location/introduction for further details.

The productpage onReady() event grabs the first product’s details and then the wix-location onChange() event grabs any other products details where they are navigated to via the Prev and Next buttons.

Big, big thanks to Dara at Wix Support for helping me with this.