Saturday, August 11, 2018

Woocommerce rating not showing in new custom theme

Leave a Comment

I am working on to new custom theme. I have installed woocommerce plugin. I have import product from xml files. I had tried to test rating functionality. Its working on wordpress default theme twentytwelve, twentysixteen. etc. But when I switched to my custom theme. comment section not showing rating.

Take a look on screenshot. Comment section has only textarea.

Here is my code of comments.php

<div class="comments">     <?php if (post_password_required()) : ?>     <p><?php _e( 'Post is password protected. Enter the password to view any comments.', 'html5blank' ); ?></p> </div>      <?php return; endif; ?>  <?php if (have_comments()) : ?>      <h2><?php comments_number(); ?></h2>      <ul>         <?php wp_list_comments('type=comment&callback=html5blankcomments'); // Custom callback in functions.php ?>     </ul>  <?php elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) : ?>      <p><?php _e( 'Comments are closed here.', 'html5blank' ); ?></p>  <?php endif; ?>  <?php comment_form(); ?>  </div> 

my screenshot

4 Answers

Answers 1

You might need to declare WooCommerce support if you are using custom theme in order to make it compatible with WooCommerce. Default WordPress themes would be normally compatible with WooCommerce and they will work without adding anything. You can read more here - https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/.

Step 1: Add this to your theme's 'functions.php'.

function custom_theme_setup() {     add_theme_support( 'woocommerce' ); } add_action( 'after_setup_theme', 'custom_theme_setup' ); 

Step 2: If still reviews not showing, copy your theme's 'page.php' as 'woocommerce.php'. Remove the loop - <?php if(have_posts()): while(have_posts()): the_post(); ?> and <?php endwhile; endif; ?>. Replace the_content() with woocommerce_content().

Let me know whether these fixes the issue, else paste new 'woocommerce.php' contents in your question.

Answers 2

If you are creating custom theme then you have to copy templates from woocommerce to your custom theme then add folder name woocommerce to your custom theme.

Then copy single-product-reviews.php from plugins -> woocommerce -> templates and paste it to your custom theme newly created folder name woocommerce

Now you can customize your review template as per your need.

Answers 3

If you want to add ratings to comment section.

  1. You can follow this link to add through code
  2. You can use this plugin (Comment Rating Field Plugin) to add this

Answers 4

It might be a Setting issue in WooCommerce. Go to WooCommerce Menu, then to Settings -> Products Tab. You can find the options to Enable Rating and Review. Please check the screenshot.

enter image description here

Hope this will help you.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment