
Originally Posted by
torvista
Try again, same file location.
I assume the reviews are shown in the head, just the aggregate was wrong.
Yes you are correct.
Still showing the same thing
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "0",
"reviewCount": "3"
the old file shows it this way
Code:
if (!$reviews->EOF) {
foreach ($reviews as $review) {
$reviewsArray[] = [
'id' => $review['reviews_id'],
'customersName' => $review['customers_name'],
'reviewsRating' => $review['reviews_rating'],
'dateAdded' => (!empty($review['date_added']) ? $review['date_added'] : PLUGIN_SDATA_REVIEW_DEFAULT_DATE), // $review['date_added'] may be NULL
'reviewsText' => $review['reviews_text']
];
$ratingSum += $review['reviews_rating']; // mc12345678 2022-07-04: If going to omit this review now or in the future, then need to consider this value.
}
$reviewCount = count($reviewsArray);
$ratingValue = round($ratingSum / ($reviewCount), 1);
}
and the new file shows it this way
Code:
if ($is_product_page || $current_page === 'product_reviews') {
$ratingSum = 0;
$ratingValue = 0;
$reviewCount = 0;
// $reviewsArr may already have been loaded on product_review page or on product_info page
if (count($reviewsArr) === 0) {
$reviewQuery = 'SELECT r.reviews_id, r.customers_name, r.reviews_rating, r.date_added, r.status, rd.reviews_text
FROM ' . TABLE_REVIEWS . ' r
LEFT JOIN ' . TABLE_REVIEWS_DESCRIPTION . ' rd ON rd.reviews_id = r.reviews_id
WHERE products_id = ' . (int)$_GET['products_id'] . '
AND status = 1
AND languages_id= ' . $_SESSION['languages_id'] . '
ORDER BY reviews_rating DESC';
$reviews = $db->Execute($reviewQuery);
if (!$reviews->EOF) {
//reviews found
foreach ($reviews as $review) {
$reviewsArr[] = [
'id' => $review['reviews_id'],
'customersName' => $review['customers_name'],
'reviewsRating' => $review['reviews_rating'],
'dateAdded' => (!empty($review['date_added']) ? $review['date_added'] : PLUGIN_SDATA_REVIEW_DEFAULT_DATE), // $review['date_added'] may be NULL
'reviewsText' => $review['reviews_text']
];
$ratingSum += $review['reviews_rating']; // mc12345678 2022-07-04: If going to omit this review now or in the future, then need to consider this value.
}
//reviews NOT found
} elseif (PLUGIN_SDATA_REVIEW_USE_DEFAULT === 'true') {
$reviewsArr[0] = [
'id' => 0, // not used
'customersName' => 'anonymous',
'reviewsRating' => (int)PLUGIN_SDATA_REVIEW_DEFAULT_VALUE,
'dateAdded' => $product_date_added,
'reviewsText' => ''
];
$ratingSum = (int)PLUGIN_SDATA_REVIEW_DEFAULT_VALUE;
}
}
$reviewCount = count($reviewsArr);
$ratingValue = round($ratingSum / $reviewCount, 1);
}
Bookmarks