How to connect product name from Customer Reviews to text field on Lightbox?

Recently I added “Ratings and Reviews” to my Wix Store. I followed the the instructions on the article below and everything works great!

https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

I decided to add a “Verified Reviews” button to my home page, this button opens a Lightbox where it shows all the ratings and reviews customer have submitted for every single product on my Wix Store, this Lightbox displays the following information: Customer Name, Review Title, Review Text, Date Submitted, Ratings (1-5) and an Optional Product Picture. I’m just missing the “Product Name” information so other customers know which product was reviewed. I have try everything to my knowledge but I can’t seem to get it to work. I have two datasets (“Reviews” and “Reviews-Stats”) created for the “Ratings and Reviews” to work and some code I had to add to the “Product Page” (Pictures below…) Please help me connect the “Product Name” from the products reviewed to text field “text64” on the “Verified Reviews” Lightbox. The only data I was able to successfully display on that text field was “ID” information since it’s on both datasets as “ID” or “productID” but I want the “Product Name” (not on any of the datasets).

Thank you in advance!


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

let product; 

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

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

async function loadStatistics() {
 const stats = await wixData.get('review-stats', product._id) ; 
 if (stats) { 
 let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10); 
 let percentRecommended = Math.round(stats.recommended / stats.count * 100); 
 let ratings = $w('#generalRatings');
  ratings.rating = avgRating;
  ratings.numRatings = stats.count;
  $w('#recoPercent').text = `${percentRecommended} % would recommend`; 
  $w('#generalRatings').show(); 
 } else {
  $w('#recoPercent').text = 'There are no reviews yet'; 
 }
 $w('#recoPercent').show(); 
}

export function reviewsRepeater_itemReady($w, itemData, index) {
 if (itemData.recommends) {
  $w('#recommendation').text = 'I recommend this product.'; 
 } else {
  $w('#recommendation').text = "I don't recommend this product.";
 }
 if (itemData.photo) { 
  $w('#reviewImage').src = itemData.photo;
  $w('#reviewImage').expand();
 }
 $w('#oneRating').rating = itemData.rating; 
 let date = itemData._createdDate; 
 $w('#submissionTime').text = date.toLocaleString();
}

export function showReviews() {
 if ($w('#Reviews').getTotalCount() > 0) {
  $w('#reviewsStrip').expand();
 } else {
  $w('#reviewsStrip').collapse();
 }
}

export async function addReview_click(event, $w) {
 const dataForLightbox = {
  productId: product._id
 };
 let result = await wixWindow.openLightbox('Review Box', dataForLightbox);
 $w('#Reviews').refresh();
 loadStatistics();
 $w('#thankYouMessage').show();
}

export function resultsPages_click(event, $w) {
 $w('#Reviews').loadMore();
}

Hey Alejandro,

If you followed the tutorial you should have a reference field in your reviews collections which references the product name from the product collection.

You can use the queryReferenced() function to query this field and display the product name on an element.

Hope this helps!

Dara | Corvid Team