Repeater Keeps Vanishing

Im currently adding a store product review from template

i have it working so i can submit the reviews and it calculates etc but the lets says customers review shows then vanishes

No errors in code

this is the full code on the page and its under the review section not the wishlist which works fine

//-------------Imports-------------//

// Import the wix-data module for working with queries.
import wixData from ‘wix-data’;
// Import the wix-users module for working with users.
import wixUsers from ‘wix-users’;

//-------------Global Variables-------------//

// Current product.
let product;
// Current user.
let user = wixUsers.currentUser;

//-------------Page Setup-------------//

$w.onReady( async function () {
// Get the currently displayed product.
product = await $w(‘#pageApp1’).getProduct();
// Check if the current product is in the wishlist and act accordingly.
checkWishlist();
// Set the action that occurs when the login message is clicked to be the loginMessageClick() function.
$w(‘#loginMessage’).onClick(loginMessageClick);
});

// Check if the current product is in the wishlist and act accordingly.
async function checkWishlist() {
// If the current user is logged in:
if (wixUsers.currentUser.loggedIn) {
// Query the “products-wishlist” collection to find if the product was already added to the user’s wishlist.
let wishListResult = await wixData.query(“products-wishlist”)
.eq(“product”, product._id)
.eq(“userId”, user.id)
.find();

// If the product was already added to the user’s wishlist:
if (wishListResult.items.length > 0)
// Show the “inWishList” image with a fade effect.
$w(‘#inWishList’).show(‘fade’, {duration: 100});
// If the product was not yet added to the user’s wishlist:
else
// Show the “notInWishList” image with a fade effect.
$w(‘#notInWishList’).show(‘fade’, {duration: 100});
}
// If the current user is not logged in:
else {
// Show the “notInWishList” image with a fade effect.
$w(‘#notInWishList’).show(‘fade’, {duration: 100});
}
}

//-------------Event Handlers-------------//

// Set the action that occurs when the “inWishList” image is clicked.
export function inWishList_click(event, $w) {
// If the current user is logged in:
if (user.loggedIn)
// Remove the current product from the wishlist.
removeFromWishlist();
}

// Set the action that occurs when the “notInWishList” image is clicked.
export function notInWishList_click(event, $w) {
// If the current user is logged in:
if (user.loggedIn)
// Add the current product to the wishlist.
addToWishlist()
// If the current user is not logged in:
else
// Show the login message.
$w(‘#loginMessage’).show();
}

// Set the action that occurs when the login message is clicked.
async function loginMessageClick() {
// Set the login options.
let options = {“mode”: “login”};
// Hide the login message.
$w(‘#loginMessage’).hide();
// Prompt the user to login using the options created above.
await wixUsers.promptLogin(options);
}

//-------------Wishlist Functionality-------------//

// Add the current product to the current user’s wishlist and update the page accordingly.
async function addToWishlist() {
// Create the wishlist item relating the current product to the current user.
let wishListItem = {
product: product._id,
userId: user.id
};

// Hide the “notInWishList” image with a fade effect.
$w(‘#notInWishList’).hide(‘fade’, {duration: 100});
// Show the “inWishList” image with a fade effect.
$w(‘#inWishList’).show(‘fade’, {duration: 100});
// Insert the item created above into the “products-wishlist” collection.
let result = await wixData.insert(“products-wishlist”, wishListItem);
}

// Remove the current product to the current user’s wishlist and update the page accordingly.
async function removeFromWishlist() {
// Query the “products-wishlist” collection to find the wishlist item corresponding to the current product and current user.
let wishListResult = await wixData.query(“products-wishlist”)
.eq(“product”, product._id)
.eq(“userId”, user.id)
.find();

// If a wishlist item was found:
if (wishListResult.length > 0) {
// Show the “notInWishList” image with a fade effect.
$w(‘#notInWishList’).show(‘fade’, {duration: 100});
// Hide the “inWishList” image with a fade effect.
$w(‘#inWishList’).hide(‘fade’, {duration: 100});
// Remove the wishlist item from the “products-wishlist” collection.
await wixData.remove(“products-wishlist”, wishListResult.items[0]._id)
}
}
//Review

//-------------Imports-------------//

import wixWindow from ‘wix-window’;

//-------------Global Variables-------------//

// Current product.
let productid;

//-------------Page Setup-------------//

$w.onReady( async function () {
// Set the global product variable to the currently displayed product.
product = await $w(‘#pageApp1’).getProduct();
// Load the current product’s reviews using the initReviews() function.
initreviews();
});

// Loads the current product’s reviews.
function initreviews() {
// Filter the “Reviews” dataset to contain only the reviews on the currently displayed product.
$w(‘#reviews’).setFilter(wixData.filter().eq(‘productId’, product._id));
// Load the current product’s statistics using the loadStatistics() function.
loadStatistics();
}

// Load the current product’s statistics.
async function loadStatistics() {
// Get the statistics data based on the current product’s ID.
const stats = await wixData.get(‘Review-stats’, product._id);
// If statistics data for the product was found:
if (stats) {
// Compute the product’s average rating by dividing the total points by the number of ratings.
let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10);
// Compute the percentage of reviewers that recommend the product.
let percentRecommended = Math.round(stats.recommended / stats.count * 100);
// Get the ratings element.
let ratings = $w(‘#generalRatings’);
// Set the ratings element’s average rating to the value calculated above.
ratings.rating = avgRating;
// Set the ratings element’s number of ratings to the count value from the statistics data.
ratings.numRatings = stats.count;
// Set the text for the recommended percentage element.
$w(‘#recoPercent’).text = ${percentRecommended} % would recommend;
// Show the ratings element.
$w(‘#generalRatings’).show();
// If there is no statistics data for the product:
} else {
// Set the text for the recommended percentage element to reflect the fact that there are no reviews.
$w(‘#recoPercent’).text = ‘There are no reviews yet’;
}
// Show the recommended percentage element only after it is populated to avoid flickering.
$w(‘#recoPercent’).show();
}

//-------------Repeater Setup -------------//

// Set up each item in the reivews repeater as it is loaded.
export function reviewsRepeater1_itemReady ($w, itemData, index) {
// If the reviewer recommends the item:
if (itemData.recommends) {
// Set the "recommend text.
$w(‘#recommendation’).text = ‘I recommend this product.’;
// If the reviewer does not recommend the item:
} else {
// Set the “don’t recomend” text.
$w(‘#recommendation’).text = “I don’t recommend this product.”;
}

// If a photo was uploaded for the review:
if (itemData.photo) {
// Set the image URL from the item data.
$w(‘#reviewImage’).src = itemData.photo;
// Expand the image.
$w(‘#reviewImage’).expand();
}

// Set the ratings element’s rating value.
$w(‘#oneRating’).rating = itemData.rating;

// Get the date that the review was entered.
let date = itemData._createdDate;
// Format the date according to the date format settings on the user’s computer.
$w(‘#submissionTime’).text = date.toLocaleString();
}

//-------------Data Setup -------------//

// Perform some setup when the page’s data is ready.
export function reviews_ready() {
// If at least one review has been submitted:
if ($w(‘#reviews’).getTotalCount() > 0) {
// Expand the strip that displays the reviews.
$w(‘#reviewsStrip’).expand();
// If there are no reviews:
} else {
// Collapse the strip that displays the reviews.
$w(‘#reviewsStrip’).collapse(); //otherwise, hide it
}
}

//-------------Event Handlers -------------//

export async function addReview_click(event, $w) {
// Create an object containing the current product’s ID to be sent to the review writing lightbox.
const dataForLightbox = {
productId: product._id
};
// Open the “Review Box” lightbox, send it the object created above, and wait for it to close.
let result = await wixWindow.openLightbox(‘Review Box’, dataForLightbox);
// After the review lightbox is closed, refresh the reviews dataset so the new review appears on the page.
$w(‘#reviews’).refresh();
// Reload the current products statistics to reflect the new rating.
loadStatistics();
// Show a thank you message.
$w(‘#thankYouMessage’).show();
}

// Set the action that occurs when a user clicks the “Load More” text.
export function resultsPages_click(event, $w) {
// Load additional reviews into the reviews repeater.
$w(‘#reviews’).loadMore();
}

website www.dogschoiceuk.co.uk

Hi Robert,
My suggestion is to add console.log and debuggers to the relevant functions (the functions that uses $w(‘yourRepeater’).hide()/collapse()) to check when it hits them.
Roi.

thanks for the hint ill see if I know how to add the console.log

still not working but the wix example works fine once published