1

I am learning WooCommerce development. I would like to display the stars rating at top of the heading so I tried like this (Not a review, it's just an example):

 function action_woocommerce_single_product_review() {
      //I don't want to show any content here    
 } 
  add_action( 'woocommerce_single_product_summary', 'action_woocommerce_single_product_review', 1, 0 ); 

I also tried using jQuery which is working:

$(".woocommerce-product-rating").insertBefore('.product_title'); 
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
user9437856
  • 2,360
  • 2
  • 33
  • 92
  • See the hooks visual guide and priority here - you can move the block by changing the priority https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ – mujuonly Jan 21 '21 at 09:33
  • @mujuonly, I just added add_action( 'woocommerce_single_product_summary', 'action_woocommerce_single_product_review', 1, 0 ); but nothing is working – user9437856 Jan 21 '21 at 09:47
  • I have a review on my page and i have to show that on top – user9437856 Jan 21 '21 at 09:53

1 Answers1

3

To move stars ratings before product title in single product pages use:

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

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

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

Related: WooCommerce action hooks and overriding templates

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399