• Resolved hsipani

    (@hsipani)


    Currently if there is no rating, the stars and reviews are not getting displayed. I want that if there is no rating a custom text “Be the first to review” would be shown that would take them to review section. How to make this happen? This should only happen on product page.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello @hsipani ,

    I got you.

    In general, you will get the rating option with the “Be the first to review” message is shown if you enable star rating from wp-admin > WooCommerce > Settings > Products page.

    I have checked your site and it looks like it is already working properly – https://prnt.sc/109iw9f.

    If this is not what you meant, can you please share a little more details about your expected outcome? You can add a screenshot to illustrate the problem better. You can use https://snipboard.io/ to share a screenshot.

    Thank you ??

    Thread Starter hsipani

    (@hsipani)

    https://snipboard.io/xX9MH6.jpg

    As you in the above image I have added product rating in my elementor page. But since none of my products have any rating this doesnt get displayed not even empty stars. I want that empty stars should be displayed and if possible instead of empty stars there should be text over there “Be the first to review” if there is no rating.

    For example check this image:-
    https://snipboard.io/cTLINt.jpg
    Since this product doesn’t have any rating it shows that text but if the product has ratings then the rating is getting displayed like this:-
    https://snipboard.io/DH0Tzk.jpg

    Hello @hsipani ,

    Thanks for the clarification. I understood your expected goal.

    First, let me explain how WooCommerce makes it work. In WooCommerce the ratings are shown on the product summary only when a rating is available. We can add additional information so that it shows a message when there are no reviews available. For this, you will have to edit this template –

    wp-content > plugins > woocommerce > single-product > rating.php

    I have extended the last part of the file to have an else condition, like this –

    <?php else :
    	$current_product = get_permalink($product->get_id());
    
    	printf('<a href="%s">Be the first to review</a>', $current_product.'#tab-reviews');
    
     endif; ?>

    The outcome is like this – https://prnt.sc/10aqcn7.

    To extend this behavior and open the actual Review tab from below you can follow this guideline and replace the “description” tab to “reviews” tab – Access WooCommerce Product Tabs Directly via URL

    Now, all of the above solutions work for the default WooCommerce single product templates. Since you are using Elementor to design your single product template they can have different ways to manage this. Product rating is a Pro feature so I am unable to test it out.

    I will recommend getting in touch with Elementor to know how can you make it work as your expectation while using their product rating widget.

    Thank you ??

    Thread Starter hsipani

    (@hsipani)

    https://snipboard.io/oNr8B1.jpg

    Just confirm if I have entered the code in right place.

    Hello @hsipani ,

    There is a slight problem with the code. You have an extra endif; statement.

    Here is the code that I used and worked for me – https://gist.github.com/rashedripon/3bf42197127e54d1336f3b147467372f

    I hope you can make it work.

    Also, make sure to save the modified file in a child theme. That will ensure that plugin updates do not remove the changes. More details here – How to Edit Files

    I hope this helps.

    Thank you ??

    Thread Starter hsipani

    (@hsipani)

    It works fine but it doesn’t scroll down to reviews section when the link is clicked. Can you give me javascript code for that?

    Hello @hsipani ,

    You can follow this article to understand how can you open the reviews tab on click- Access WooCommerce Product Tabs Directly via URL

    You need to replace the “description” tab with the “reviews” tab to make it work in your implementation.

    You can take a Woo expert’s help if you are not comfortable making the changes.

    Thank you ??

    Hi there,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ??

    Thread Starter hsipani

    (@hsipani)

    Is there a option to add the above code in child theme functions.php since with every update the code gets reremoved?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Product Rating’ is closed to new replies.