OnReady of the product page, I can call the product sku. However, when I click next/prev product it does not recall the new sku

I am trying this with both “$w.onReady( function ()” and " export function productPage1_viewportEnter(event)"

The proper sku is loaded when I click on a product from the shop. But if I click next or previous product it does not reattempt to get the sku again. I have to refresh the page for it to work.

I am trying to put the sku into a button to append to a search result.

You can add the following to the onReady() function which will cause the page to refresh when navigating to another product:

    wixLocation.onChange(async (location) => {
        wixLocation.to(wixLocation.url);
    })

Hey, Thanks! This sounds like exactly what I would need, however I am confused as to what I need to change to make it fit my code.
My thought wixLocation would be the productPage, but not sure what (location) would be.

@baileypaserk You just need to add those lines of code to the onReady() function of the Product page:

Something like this (your page of course might be slightly different):

import wixLocation from 'wix-location';

//-------------Page Setup-------------//

$w.onReady(async function () {
    // this causes the page to refresh if navigating to another product
    wixLocation.onChange(async (location) => {
        wixLocation.to(wixLocation.url);
    })
});

Actually this was the fix I needed, and I did not need to change anything. Thank you so much. I used his fix, and added the below code to the top of the file.

import wixLocation from 'wix-location';