Site logo

Archived topic

Mostrar cantidad de reseñas en categorías

3 replies · Started by Pedro on February 22, 2021

Viewing posts 1–4 of 4

Hi there,

You can try this PHP snippet:

add_filter( 'woocommerce_product_get_rating_html',function( $html ){
    global $woocommerce, $product;  

    $review_count = $product->get_review_count();
    return '<div class="rating-wrapper">'.$html.'<div class="review-count">('.$review_count.')</div></div>
	<style> ul.products .rating-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

ul.products .rating-wrapper .star-rating {
    margin: 0 !important;
}

ul.products .rating-wrapper .review-count {
    line-height: 0;
    display: flex;
    align-items: center;
} </style>
	';
});

Hola Elvin,

Gracias por la ayuda.

El código funcionó de maravilla, sin embargo no se ve correctamente.

Aquí puedes ver como queda: https://mega.nz/file/2pl1zCgY#9yQ6M81wMPLVvxOJ4VZJqVFUvKPpH22UI7BUL9qgVVw

Sería genial si también puedo personalizar la cantidad de reseñas con CSS desde el personalizador de GeneratePress.

Como el tamaño, color, etc.

¡Gracias!

Try this instead:

add_filter( 'woocommerce_product_get_rating_html',function( $html ){
    global $woocommerce, $product;  

    $review_count = $product->get_review_count();
    return '<div class="rating-wrapper">'.$html.'<div class="review-count">('.$review_count.')</div></div>';
});

And add this CSS on Appearance > Customize > Additional CSS so it doesn't display on center:

ul.products .rating-wrapper {
    display: flex;
    flex-direction: row;
}

ul.products .rating-wrapper .star-rating {
    margin: 0 !important;
}

ul.products .rating-wrapper .review-count {
    line-height: 0;
    display: flex;
    align-items: center;
}

We basically separated the CSS from the PHP Snippet and changed the alignment.

Sería genial si también puedo personalizar la cantidad de reseñas con CSS desde el personalizador de GeneratePress.

Como el tamaño, color, etc.

You can actually control the color of the star through Appearance > Customize > Colors > Woocommerce if you have the Colors module enabled. https://docs.generatepress.com/article/colors-overview/

This archived topic is closed to new replies.