[Support request] Mostrar cantidad de reseñas en categorías

Home Forums Support [Support request] Mostrar cantidad de reseñas en categorías

Home Forums Support Mostrar cantidad de reseñas en categorías

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1668499
    Pedro

    Hola,

    Me gustaría saber cómo puedo colocar la cantidad de reseñas en de los productos al lado de las estrellas, en las páginas de categoría y tienda.

    Algo como esto: https://mega.nz/file/npdiXDBL#I3pHeJ2LJa4P6rhlmlAghqHIL1KM5yEOd_DcXjFw22E

    ¡Gracias!

    #1668552
    Elvin
    Staff
    Customer Support

    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>
    	';
    });
    #1671355
    Pedro

    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!

    #1671400
    Elvin
    Staff
    Customer Support

    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/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.