Product reviews

I spent the day working on the Wix Code, I created the wish list, related products but I grabbed trying to set up the review, I tried, I made all the changes until my brain toasting. Could someone from the Wix team help me?
This is the product page code. Here it does not open lightbox and does not show messages on the page. As I can not get the product ID so I can not check if the form will upload the review and I did not forget to call the window, nor the data base just did not put it here because I just managed to paste the piece I used the elements of the site, the rest I had to cut because it got big and I was not able to post

export function addReview_onClick(event) {
let productId = $w(β€˜#productPage’).getProduct();
wixWindow.openLightbox(β€˜Resenhas’, {id: productId});
}

function loadReviews(limit) {
let productReview = $w(β€˜#productPage’).getProduct();
wixData.query(β€˜reviews’)
.eq(β€˜productId’, productReview._id)
.find()
.then(res => {
if (res.length > 0) {
renderRating(res.items);
renderReviews(res.items, limit);
$w(β€˜#numberOfReviews’).text = ${res.length} Reviews;
$w(β€˜#numberOfReviews’).show();
if (res.length > 2) {
$w(β€˜#seeAllReviews’).show();
$w(β€˜#seeAllLine’).show();
}
}
else {
$w(β€˜#rating’).hide();
$w(β€˜#numberOfReviews’).text = β€˜Este produto ainda nΓ£o fio avaliado seja o primeiro.’;
$w(β€˜#numberOfReviews’).show();
}
});
}

let rating = Math.round(stats.sum * 2 / stats.count) / 2;
$w(β€˜#rating’).show();
// setting the rating as HTML to have fine grained control over the formatting
$w(β€˜#rating’).html = `

<span

if (odd.length > 0) {
let oddRendered = odd.map(renderReview).join(reviewSeparator) + reviewEnd;
$w(β€˜#reviewsOdd’).html = oddRendered;
$w(β€˜#reviewsOdd’).show();
$w(β€˜#oddReviewContainer’).show();
}
else {
$w(β€˜#reviewsOdd’).hide();
$w(β€˜#oddReviewContainer’).hide();
}

if (even.length > 0) {
let evenRendered = even.map(renderReview).join(reviewSeparator) + reviewEnd;
$w(β€˜#reviewsEven’).html = evenRendered;
$w(β€˜#reviewsEven’).show();
$w(β€˜#evenReviewContainer’).show();
}
else {
$w(β€˜#reviewsEven’).hide();
$w(β€˜#evenReviewContainer’).hide();
}
}

async function seeAllReviews_onClick(event) {
loadReviews();
}

1 Like