Hiding reviews from the Category/Shop page

You may like the idea of reviews but also have a few angry customers who are lowering the average rating of your product. You don't want that to impact future customers. One solution is to hide the average rating on the shop page and only show ratings on the product page, where users will be able to read the content of the review in addition to the actual star rating. That will help them understand exactly why someone doesn't like the product and the reason may not even affect them, so you could still get the sale.

How to do it...

If you look at the shop page right now, it will display a star rating based on an average of all of the reviews, as shown in following screenshot:

How to do it...

The star rating is added to the page with an action attached to a hook. We're going to use the hook system to remove that action. Let's take a look at the following steps:

  1. Open up your theme's functions.php file or a custom WooCommerce plugin.
  2. Add the following code to the bottom of the file:
    remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
  3. Save and upload the file.

There's more...

There are tons of hooks in WooCommerce that you can take advantage of. You can add or remove actions that will change when a specified programming action takes place or if it takes place at all. If you want to have an idea of what can be moved around, look at the templates located in the woocommerce plugin under templates.

There is a tutorial in the Using WooCommerce hooks recipe in Chapter 9, WooCommerce Theming, that shows you how to take advantage of these hooks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset