add_action('woocommerce_shop_loop_item_title', 'add_rating_and_review_count_below_title', 10);

function add_rating_and_review_count_below_title() {
    global $product;

    $average = $product->get_average_rating(); // Note moyenne
    $count = $product->get_rating_count(); // Nombre d'avis

    if ($average && $count > 0) {
        echo '<div class="woocommerce-product-rating" style="display: flex; align-items: center; gap: 5px; margin-top: 5px;">';
        echo '<span class="star-rating" >'. wc_get_star_rating_html($average) .'</span>'; // Affiche les étoiles
        echo '<span>(' . $count . ' ' . __('avis', 'woocommerce') . ')</span>'; // Affiche le nombre d'avis
        echo '</div>';
    }
}
