rating, share and review issue for single WooCommerce page

I try to give you some cleanup solution which is basic code setup.

For social share:
See plugin Social Sharing Toolkit Which is easy sharing and connecting on social networks. Display on posts or use widgets or shortcode. Also Twitter name/hashtag to link converter.

use do_shortcode('[social_share]') for display social share anywhere on site. In woocoomrce Product page use this code in content-single-product.php file.

For Star rating:
There is a sort logic here for if you need star rating at your single product, then you will need to do template editing.

Edit your /x/woocommerce/single-product/rating.php and add this code before ?>

GLOBAL $product; echo '<div class="star-rating-container aggregate">' . $product->get_rating_html() . '</div>';

This will add star rating below product title. See more at here.

With above solution, I’m not sure about that so if you want to go with your risk.

You can put this into your themes functions.php file:

add_action('woocommerce_after_shop_loop_item', 'my_print_stars' );


function my_print_stars(){
    global $wpdb;
    global $post;
    $count = $wpdb->get_var("
    SELECT COUNT(meta_value) FROM $wpdb->commentmeta
    LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
    WHERE meta_key = 'rating'
    AND comment_post_ID = $post->ID
    AND comment_approved = '1'
    AND meta_value > 0
");

$rating = $wpdb->get_var("
    SELECT SUM(meta_value) FROM $wpdb->commentmeta
    LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
    WHERE meta_key = 'rating'
    AND comment_post_ID = $post->ID
    AND comment_approved = '1'
");

if ( $count > 0 ) {

    $average = number_format($rating / $count, 2);

    echo '<div class="starwrapper" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';

    echo '<span class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woocommerce'), $average).'"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> </span></span>';

    echo '</div>';
    }

}

Note that you may need to change ‘woocommerce_after_shop_loop_item‘ to a different hook depending on your design and where exactly you want the stars to show up.

For more detail please check wooCodex.

Hope this help you well!