# 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

**URL:** <https://forum.wixstudio.com/t/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/8340>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [March 11, 2021, 2:41am UTC](https://forum.wixstudio.com/t/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/8340 "2021-03-11T02:41:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![baileypaserk](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@baileypaserk](https://forum.wixstudio.com/u/baileypaserk)\
**Post date:** [March 11, 2021, 2:41am UTC](https://forum.wixstudio.com/t/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/8340/1 "2021-03-11T02:41:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [March 11, 2021, 6:58am UTC](https://forum.wixstudio.com/t/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/8340/2 "2021-03-11T06:58:11Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![baileypaserk](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@baileypaserk](https://forum.wixstudio.com/u/baileypaserk)\
**Post date:** [March 11, 2021, 2:40pm UTC](https://forum.wixstudio.com/t/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/8340/3 "2021-03-11T14:40:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [March 11, 2021, 2:46pm UTC](https://forum.wixstudio.com/t/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/8340/4 "2021-03-11T14:46:46Z")

</div>

@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):

```javascript
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);
    })
});

```

---

<div class="post-metadata">

**Author:** ![baileypaserk](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@baileypaserk](https://forum.wixstudio.com/u/baileypaserk)\
**Post date:** [March 11, 2021, 3:05pm UTC](https://forum.wixstudio.com/t/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/8340/5 "2021-03-11T15:05:09Z")

</div>

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.

```javascript
import wixLocation from 'wix-location';

```
