Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17160

    Hi,

    How can I add star ratings under ‘Add to Cart’ button. Below is the screenshot.

    11az8kw.jpg

    #94392

    You can try to add following code to functions.php (at the very bottom):

    add_filter( 'woocommerce_after_add_to_cart_button', 'ino_add_rating_stars' );
    function ino_add_rating_stars()
    {
    global $product;
    echo $product->get_rating_html();
    }

    You can also try to use the woocommerce_after_add_to_cart_button instead of the woocommerce_before_add_to_cart_button hook.

    #94395

    Hi,

    Thanks! The code still not working. Now it doesn’t color the stars based on previous reviews.

    Please see below screenshot.

    34ydzqg.png

    #94396

    Hey!

    My mistake – I used the code for the single star rating. I adjusted the code and it will display the average rating now.

    Best regards,

    Peter

    #94397

    You are genius Peter. Thanks the above code is working fine.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Product page star rating under cart button’ is closed to new replies.