Home Forums Basel support forum Stars and number of reviews always visible with products?

Stars and number of reviews always visible with products?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #3212

    Pat84
    Participant

    Hi there, my favourite theme so far! Is there a way to show the review stars everywhere along with the products? At the moment, the only way to see the reviews is on the product page; I would like to have the stars and number of reviews always visible with the products everywhere. Is there a way to do so?

    Pat

    #3226

    Artem Temos
    Keymaster

    Hello,

    Thank you for contacting our support center.

    The problem is that hover effect for products that you use on your web-site doesn’t have rating stars. Try to use another one that you may find in Theme Settings -> Shop. If you still want to use current hover effect you will need to make a small code customization. Write us if you need some instructions.

    Regards

    #3241

    Pat84
    Participant

    Thanks! I managed to show the stars but I would like to have the number of reviews between parenthesis, something like: 5stars (140)

    Is this too complicated to do?

    Thanks again 🙂

    Pat

    #3248

    Artem Temos
    Keymaster

    We would be glad to help you but it requires a bit more PHP code customization and we don’t have quick instruction for you about this question.

    #3249

    Pat84
    Participant

    I think I should use

    $rating_count = $product->get_rating_count();

    I found this piece of code too:

    <div class="product-ratings">
    	<?php if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
    		return;
    	}
    
    	$rating_count = $product->get_rating_count();
    	$review_count = $product->get_review_count();
    	$average      = $product->get_average_rating();
    
    	if ( $rating_count > 0 ) : ?>
    
    		<div class="woocommerce-product-rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    			<div class="star-rating" title="<?php printf( __( 'Rated %s out of 5', 'woocommerce' ), $average ); ?>">
    				<span style="width:<?php echo ( ( $average / 5 ) * 100 ); ?>%">
    					<strong itemprop="ratingValue" class="rating"><?php echo esc_html( $average ); ?></strong> <?php printf( __( 'out of %s5%s', 'woocommerce' ), '<span itemprop="bestRating">', '</span>' ); ?>
    					<?php printf( _n( 'based on %s customer rating', 'based on %s customer ratings', $rating_count, 'woocommerce' ), '<span itemprop="ratingCount" class="rating">' . $rating_count . '</span>' ); ?>
    				</span>
    			</div>
    			<?php if ( comments_open() ) : ?><a href="#reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'woocommerce' ), '<span itemprop="reviewCount" class="count">' . $review_count . '</span>' ); ?>)</a><?php endif ?>
    		</div>
    
    	<?php endif; ?>
    </div><!-- .product-ratings -->

    As I am not a developer I would not try to place this on my website but I would appreciate if you guys could put me on the right track.

    Thanks in advance.

    Pat

    #3260

    Artem Temos
    Keymaster

    Okay, just try to place it some of the content product files basel/woocommerce/content-product-*.php depending on what hover effect do you use.

    #3279

    Pat84
    Participant

    I like that “just try”. I reckon, if there might be the chance to screw up my website, you should not say “just try”. Is the answer: “Yes, it might work” or “better leave it to the experts”?

    Thank you,

    Pat

    #3285

    Artem Temos
    Keymaster

    Okay, sorry for that. But is there any difference between “just try” and “it might work”? In both cases, any peace of code possible may throw some warning or fatal error and break your site. And it is impossible to say that it will 100% work fine. But if you place this code to your file via FTP (FileZilla for example) and see that site doesn’t work you can remove your code and return old file just in a few seconds.

    Anyway, maybe the best answer to this question will “better leave it to the experts” 🙂

    Regards

Tagged: 

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