Home Forums WoodMart support forum Add empty star rating to pages

Add empty star rating to pages

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

    rhg-designs
    Participant

    Hi,

    I wanted to know if it is possible to add an empty star rating to the shop page and product page so the review star rating always will be shown also when the product has no reviews. I made this possible in other theme’s but cannot get it done now 😉 So please help me out. (I filled in one test review and it would look so much nicer when there are empty stars for products without a rating)

    Thanks!

    Attachments:
    You must be logged in to view attached files.
    #188556

    Hello,

    First of all thanks for choosing our Theme, we are glad to be you in the WoodMart WordPress family :-).

    I saw the screenshot you attached. Unfortunately, there is no option in theme settings available to display the empty star rating to the products. You need to add some reviews for the products to display star rating.

    Because the star rating is WooCommerce functionality and our theme doesn’t influence this.

    You can try adding any third party plugin that better meets your requirements.

    Best Regards.

    #188938

    rhg-designs
    Participant

    Thanks for your response. I managed to get it with some custom code. Here is the code so you can provide it if someone asks the same question in the future!

    add_action(‘woocommerce_after_shop_loop_item’, ‘add_star_rating’ );
    function add_star_rating()
    {
    global $woocommerce, $product;
    $average = $product->get_average_rating();

    echo ‘<div class=”star-rating”><span style=”width:’.( ( $average / 5 ) * 100 ) . ‘%”><strong itemprop=”ratingValue” class=”rating”>’.$average.’ ‘.__( ‘out of 5’, ‘woocommerce’ ).'</span></div></br>’;
    }

    Attachments:
    You must be logged in to view attached files.
    #189041

    Hello,

    We are Glad that you found the solution by yourself. You are Great!!

    Your solution might be useful for someone else.

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Topic Closed.
    Best Regards.

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Add empty star rating to pages’ is closed to new replies.