.getProduct() is not a function

The code which was working fine a week back is broken at the above query.

Background:
I have built a store page with an extended product page with extended features and options.

$w.onReady(async() => {
    product = await $w('#productPage1').getProduct();
    //$w('#imagePreviewHorizontal').src = product.imagekey;
    console.log('product =>', product);
    $w('#boxHorizontal').show();
    $w('#boxVertical').hide();
    loadInitInfo();
    generateRatings();
    for (var type in radio_options){
        $w(radio_options[type]).disable();
    }
    load_inits();
    $w('#repeaterDataset').setFilter(wixData.filter()
        .eq('products', product._id)
    );
    if ($w('#repeaterDataset').getTotalCount() < 1){
        $w('#repeater1').collapse();
        $w('#loadMoreReviews').hide();
    }
});

Anybody encountered this recently?

1 Like

Did you create your own ratings and reviews for Wix Stores similar to this Wix tutorial here?
https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

As note in that tutorial…

There are two ways to filter a dataset: using code (as in this example) or via the Dataset Settings panel of the dataset.

async function initReviews() {
await $w('#Reviews').setFilter(wixData.filter().eq('productId', product._id));
showReviews();
loadStatistics();
}

Line 2: Chain an eq function to setFilter to filter out all items in the Reviews dataset where the product ID doesn’t match the ID of the currently displayed product.

If you want to use this exact scenario and code in your site, you may need to modify these items to match the ones on your site:

  • #Reviews

  • productId

Also, just to make sure that you do have the required imports and the let at the top of your code as mentioned in the tutorial too.

Plus, try changing your code back to how it was written in the tutorial as $w.onReady(async function () { instead of writing it like you have as $w.onReady( async () => { - just covering all bases here as it should not matter.

import wixData from 'wix-data';
import wixWindow from 'wix-window';

let product;   

$w.onReady(async function () {
product = await $w('#productPage1').getProduct();
initReviews();
});

Lines 1-2: Import the modules we need to work with Wix Data and Wix Window libraries.
Line 5: Define the global product variable.
Line 7: When the page loads, do the following:
Line 8: Using the getProduct function on the current product page, set the product variable to the currently displayed product.
Line 9: Run the initReviews function to load the current product’s ratings and reviews.

Thanks for the quick reply. No - the review and rating does not follow the mentioned tutorial. My program is breaking in the first line of onReady -
product = await $w(‘#productPage1’).getProduct();
which was working as it is few days back.

I am getting the same error in my code too. I am new to corvid and wix . I was trying few things for my new website. The get.product function was working perfectly on Feb 18 2020. But not working today. No change was made . I tried restoring site to the older version and tried coding again . I get the same error. Please advise
Here is the code
$w(‘#productPage1’).getProduct()
.then( (product) => {
ProductVariant(product._id,VariantDays())
.then((variants)=>{

$w(‘#DailyRate’).text=variants.items[0].variant.formattedPrice;
if (variants.items[1].variant.visible === true && variants.items[1].variant.price > 0) {
$w(‘#WeeklyRate’).text=variants.items[1].variant.formattedPrice;

}
if (variants.items[2].variant.visible === true && variants.items[2].variant.price > 0) {
$w(‘#MonthlyRate’).text=variants.items[2].variant.formattedPrice;

}

});

});

This is now a BLOCKER for me. Not sure how to reach out to the WIX guys, to register a valid bug. Not able to update my site (premium service) with new content unless this is resolved.

This is a known issue. Check this comment .

Thanks Shan

Hi! Please send us your site and Editor link for further investigation

Thanks Angelina.
https://editor.wix.com/html/editor/web/renderer/edit/42cdaf1a-b4b1-4f2f-b75a-279a4b1ad86c?metaSiteId=c641d8f3-b99d-40da-bec3-0474961721e0&editorSessionId=73237f19-84c9-428b-93b8-767685acbeec&referralInfo=dashboard

Hi,
I see that the issue was fixed and the error should no longer occur.

Please let the Wix support know if it occurs again.

Just Tested. Fixed. Thanks heaps

I have the issue while following the tutorial: https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

I am using default product page and checked the ID is correct.
However, I still get .getProduct() is not a function

I am also still getting the error

I am using default product page and checked the ID is correct.
However, I still get .getProduct() is not a function

@cotswolddogboutique I published the website, then the function works fine. Only the editor doesn’t detect it…

@juny929 thank you, I have just just checked my published version and all the shop pages and sliders are missing, is this something disabled on your end?

@cotswolddogboutique That happens me now… All contents from database are missing in my published website.

Seems to be an issue again, sometime it’ll work, sometimes it won’t

Have you find the way to recreate the issue?

If possible, can you post the product page that does not work?

@certified-code its happening every time. the product page is: https://www.ashfieldvaletingsupplies.co.uk/product-page/blood-rain-500ml
I can see it failing in the console.