Ron
Ron

Reputation: 41

How to change the position of star ratings on a single product page in woocommerce?

I am currently working on moving the star rating from underneath add to cart button to below the single product title position.

Original pic.

For that, I am using hooks in my child theme's function.php file:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );

add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 6 );

But I get the strange result, look at it yourself

Result

Good news is that I have the second rating, but why is the remove_action not removing the original star rating? As you can see, now I have two duplicate star ratings.

Here is the link to the website >>>

Upvotes: 2

Views: 5495

Answers (1)

Swapnali
Swapnali

Reputation: 1299

You can move the star rating from underneath add to cart button to below the single product title -

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );

add_action('init', 'add_new_star_rating');
    function add_new_star_rating()
    {
      add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 6 );
    }

use this code in function.php file.

Upvotes: 4

Related Questions