Hi,
Getting ediror error + code is not executed.
The console.log is not printed.
Please advise:)
Dafna
Your code looks fine (the fact that âgetProductâ is red will be resolved soon, but itâs not related to your issue)
Here are some ways you can debug this:
- Verify that âproductPageâ is the correct id of your product page
- Simplify your code, just do $w(â#productPageâ).getProduct().then(console.log).catch(console.log) and see if you get anything printed out
- Check the console for errors
If you are unable to resolve this, please send me your site address so I can have a look
Thanks,
Oded
Hi,
itâs not printing the log.
site: brinadavid
url: https://www.brinadavid.co.il/Stores/Products/36ccb2bc-f1cf-a720-b573-8b3d0f14f7f1
This product id is for a product that has the relevant setup
The code is under the product dynamic page
Thanks a lot!
Dafna:)
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
Not sure I understand
Let me try and explain.
When you install stores, you get 4 pages added to your site:
- Shop (פ×ר×ת)
- Product Page (under פ×ר×ת)
- Thank you page (under פ×ר×ת)
- 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
ok. got it form data query:)
Thanks
Hi:)
Another post regarding Wix Stores with code:
Thanks a lot,
Dafna
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 Alan,
Unfortunately this looks like an issue in our side, Iâm looking into this and will let you know
Thanks,
Oded
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
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 is off topic and not related to âgetProductâ, would you mind creating a new forum post?
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-ĺ¸ĺŚć˝é˘ĺŤĺą
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
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 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?
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 Christian,
There was an issue specifically with your store (on our end) I fixed it and things seems to be working now.
Thanks,
Oded
Thank you very much for your quick response and resolution! Christian