Support » Plugin: WooCommerce » Display Empty Review Stars

  • I would like to display empty review stars with each product, meaning, display the stars even if there aren’t any reviews left for the product. Just empty ones.

    I use to use this code:

    add_filter('woocommerce_product_get_rating_html', 'your_get_rating_html', 10, 2);
    
    function your_get_rating_html($rating_html, $rating) {
        if ( $rating > 0 ) {
            $title = sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating );
        } else {
            $title = 'Not yet rated';
            $rating = 0;
        }
    
        $rating_html  = '<div class="star-rating" title="' . $title . '">';
        $rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'woocommerce' ) . '</span>';
        $rating_html .= '</div>';
        return $rating_html;
    }

    But it appears it’s no longer working on WooCommerce 3.0. Any help in getting this code to work again would be great appreciated.

  • The topic ‘Display Empty Review Stars’ is closed to new replies.