Get star rating for woocommerce
Fri Sep 13 2024 04:20:49 GMT+0000 (Coordinated Universal Time)
Saved by
@tiendat
function customRatingScoreHTML($productID)
{
$product = wc_get_product($productID);
$average = $product->get_average_rating();
$rating_whole = floor($average);
$rating_fraction = $average - $rating_whole;
$flug = 0;
for ($i = 1; $i <= 5; $i++) {
if ($i <= $rating_whole) {
echo '<i class="fas fa-star"></i>';
} else {
if ($rating_fraction > 0 && $flug == 0) {
echo '<i class="fas fa-star-half-alt"></i>';
$flug = 1;
} else {
echo '<i class="far fa-star empty"></i>';
}
}
}
}
content_copyCOPY
Comments