hello friends!
I add reviews to my store with Corvid a while ago… and it used to work,
but now, suddenly it’s not working anymore, although I did not change anything.
I tried to fix it my self and took a look again over the all guide without succes…
there is several problems:
www.eleflayla.com/herbal-remedies-store
- when I put a new review, the Review Box lightbox do not close… just all the filled fields get empty again.
- the reviews aren’t shows up… from any device, expect one! my smartphone !
but it is not shows when I surf from my laptop, or any other computer/smartphone. only from my smartphone I can see the reviews!
- when I go from the site dashboard >> database >> Reviews collection, I see the the field of “Product” are empty. in the field of ProducdId is filled but there is yellow exclamation mark that says: " This field will not appear on your live site because your structure is not in sync. "
- on the “review-stats” collection it doe not updated automatically…
all that and I didnot change nothing!! it used to work perfectly…
I did check there is event handler for everything, and the ID in the properties panel
this is the code from the product page
import wixData from 'wix-data';
import wixWindow from 'wix-window';
let product;
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} ממליצים`;
$w('#generalRatings').show();
} else {
$w('#recoPercent').text = 'עדיין אין תגובות';
}
$w('#recoPercent').show();
}
export function reviewsRepeater_itemReady($w, itemData, index) {
if (itemData.recommends) {
$w('#recommendation').text = 'אני ממליץ על מוצר זה';
} else {
$w('#recommendation').text = "אני לא ממליץ על מוצר זה";
}
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();
}
this is the code of the Review Box lightbox
import wixWindow from 'wix-window';
import wixData from 'wix-data';
let productId;
$w.onReady(function () {
productId = wixWindow.lightbox.getContext().productId;
$w('#SubmitReviews').onBeforeSave(() => {
if ($w('#radioRating').value === '') {
$w('#rateError').show();
return Promise.reject();
}
$w('#SubmitReviews').setFieldValues({
productId,
rating: $w('#radioRating').value,
recommends: $w('#radioGroup1').value
});
});
$w('#SubmitReviews').onAfterSave(async () => {
await updateStatistics($w('#radioGroup1').value);
wixWindow.lightbox.close();
});
});
async function updateStatistics(isRecommended) {
let stats = await wixData.get('review-stats', productId);
if (stats) {
stats.rating += parseInt($w('#radioRating').value, 10);
stats.count += 1;
stats.recommended += (isRecommended === "true") ? 1 : 0;
return wixData.update('review-stats', stats)
}
stats = {
_id: productId,
rating: parseInt($w('#radioRating').value, 10),
count: 1,
recommended: (isRecommended === "true") ? 1 : 0
};
return wixData.insert('review-stats', stats)
}
export function radioRating_change(event, $w) {
$w('#rateError').hide();
}