Review Prompt Below the Product Summary
Adds a "Bought this? Share your review" link with the current review count under the WooCommerce product summary, opening the Reviews tab.
Opens WPIDE on
Code
<?php
global $product;
if ( $product instanceof WC_Product && $product->get_reviews_allowed() && 'yes' === get_option( 'woocommerce_enable_reviews' ) ) :
$wpide_reviews = (int) $product->get_review_count();
?>
<p class="wpide-review-prompt" style="clear:both;margin:1em 0">
<a href="#reviews" class="woocommerce-review-link">
<?php echo esc_html( $wpide_reviews ? sprintf( 'Bought this? Add your review to the %d others', $wpide_reviews ) : 'Bought this? Be the first to write a review' ); ?>
</a>
</p>
<?php endif; ?>
Notes
The woocommerce-review-link class makes WooCommerce open the Reviews tab on click.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.