Hi,
Getting ediror error + code is not executed.
The console.log is not printed.
Please advise:)
Dafna
![](https://static.wixstatic.com/media/a27d24_a3dc8f5767304ef187f66dd007e6dfe2~mv2.png/v1/fill/w_554,h_372,al_c,q_85,enc_auto/a27d24_a3dc8f5767304ef187f66dd007e6dfe2~mv2.png)
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
The above code only works from within the product page, it does not work from a dynamic page.
Hi Oded,
i used the code below on a dynamic product page and keeps giving the error ('getProduct' does not exist on '#productPage1'), is there an alternative piece of code i can use for dynamic page??
import { session } from 'wix-storage'; import wixLocation from 'wix-location'; $w.onReady(function () { $w("#getquote").onClick((event) => { $w('#productPage1').getProduct() .then((product) => { let theProduct = product._id; session.setItem("product", theProduct); }) .then(() => { wixLocation.to("/quote"); }) .catch((error) => { console.log(error); }); }); });
getproduct is not working again
Thank you very much for your quick response and resolution! Christian
Hi Christian,
There was an issue specifically with your store (on our end) I fixed it and things seems to be working now.
Thanks,
Oded
For more info, here is a URL where the product cannot be loaded with wix code:
https://www.littlebeesplants.co.uk/product-page/allium-ambassador
And here is a product page where the same code is able to load the product and print the ID and Slug.
https://www.littlebeesplants.co.uk/product-page/dahlia-david-howard
In this case the only difference is that the 'dahlia david howard' product was added today, whereas the other product was added months ago.
Hi Oded,
I am running into this issue:
My wix code has recently stopped loading products and showing a 'product not found error' in the console, but only for older products in my site. For newer products added in the last week, the code on my product pages works fine.
Is this something you can help with?
Thanks for the fix and advice, Oded. I have just started to learn how to code like two, three weeks ago. I will try to fix it. :)
Hi Alan,
This should be fixed now
Regardless,
I noticed that your web page issues three requests to "getProduct" when looking at the network tab - the more requests you have, the slower you website will load.
I would advice that you inspect your code and fix.
Thanks,
Oded
Hi Oded, it appears that the issue with the getProduct command is reappearing. Please can you assist?
Thank you very much for your time.
https://www.ajiaj.com/product-page/eve-lom-%E5%8D%B8%E5%A6%9D%E6%BD%94%E9%9D%A2%E5%95%AB%E5%96%B1
Hi Alan, this is off topic and not related to "getProduct", would you mind creating a new forum post?
Thanks,
Oded
Thank you Oded for your reply, I made a referrer page with the following code
import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; $w.onReady(function () { let referrer = wixWindow.referrer; let url = "" + referrer; wixLocation.to(url); } );
Do you think it is possible to redirect to the referrer page on refresh? Maybe by adding a query to the link?
Hi Alan,
This issue has been resolved :) I verified and it your website seems to be working fine now.
Just one comment though - I see that have used "getProduct" in order to implement related items. Just keep in mind that clicking the related items link refreshes the item displayed on the page but "onReady" isn't called again so getProduct isn't called again. This is something that we are looking into.
In the meantime, if this important to you, you can listen to the click event on the repeater item and then get the data from the dataset. This code demonstrates the general idea:
$w.onReady(function () {
$w("#productPage1").getProduct().then(x => console.log(x.slug)).catch(console.log)
// #image1 is inside a repeater
$w("#image1").onClick((event, $w) => {
console.log($w("#dataset1").getCurrentItem().slug);
})
});
Please let me know if your have any further questions!
Thanks,
Oded
Hi Alan,
Unfortunately this looks like an issue in our side, I'm looking into this and will let you know
Thanks,
Oded
Hi there, I am getting the same error and I am using a native product page. Please can you advise?
The site is
www.ajiaj.com
Hi:)
Another post regarding Wix Stores with code:
https://www.wix.com/code/home/forum/questions-answers/wix-store-with-code-upload-is-very-long
Thanks a lot,
Dafna
ok. got it form data query:)
Thanks
Let me try and explain.
When you install stores, you get 4 pages added to your site:
1. Shop (פירות)
2. Product Page (under פירות)
3. Thank you page (under פירות)
4. Cart (under פירות)
The API you are using, allows you to read the product being presented in the "Product Page". The most common use case is to get the id of the product and then use it in another table. This allows you to extend the native product page with ratings, related items and other use cases.
I don't think this is what you need, since you creating a dynamic product page and not using the native one
Not sure I understand
It doesn't work because $w("#productPage") is not a product page.
The purpose of this API is to allow getting the product from the "native" product page, the one that is under "Product Page" page
Thanks,
Oded