0

I am using a custom Woocommerce page template for the single-product.php - however the page isn't displaying any reviews or the box to add reviews.

I have checked the settings for Woocommerce to display these and the box is checked. Is there some code that I need to include in order to display these?

Many thanks Christina

<?php if(have_posts()): ?>

    <div class="product-single">

        <?php while(have_posts()) : the_post(); ?>



            <?php the_content(); ?>

        <?php endwhile; ?>

    </div>
<?php else: ?>

    <article class="post error row contain">
        <h1 class="404">Nothing has been posted like that yet</h1>
    </article>

<?php endif; ?>
  • dropbox.com/s/5xetdbthymfvczw/… Something like this – Christina Jul 16 '18 at 19:12
  • 1
    Without posting the code for your single-product.php template there isn't much anyone can do to help. – Steve Jul 16 '18 at 19:30
  • The single product loop is not the same as the one for reviews. Have a look here or here to read up on how to add reviews to your site. If that doesn't help, then it might be an idea to let us know the name of your theme or the URL where we can see the site. – user2015 Jul 17 '18 at 20:11
0

In general, your code looks as if it's not following the proper WooCommerce theme structure. I'd review the documentation at WooCommerce docs and see the recommended methodology. WooCommerce has a great deal of good documentation on its plugin and there is a wealth of information readily available.

In particular, you need to look at your use of the_content() rather than the recommended woocommerce_content().

0

I'm using this code to display reviews:

add_action( 'woocommerce_before_single_product_summary', [ $this, 'dt_display_product_rating' ], 11 );

function dt_display_product_rating() {
        global $product;

        if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) {
            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">
                <?php echo wc_get_rating_html( $average, $rating_count ); ?>
                <?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 class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
            </div>
            <?php
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.