when enabled, every woocommerce product has a star rating. I have some custom code that I would like to replace the current star rating in its entirety (Including the "# customer reviews" part.
Currently, the code I am using only appends to the star rating, rather than replace it fully. Below is the current result I am seeing, and the code I have added to functions.php. Thank you in advance.
Code:
add_filter( 'woocommerce_get_star_rating_html', 'replace_star_ratings' );
function replace_star_ratings( $variable ) {
echo "XXX";
return $variable;
}
woocommerce_product_get_rating_html
would be the filter you want, but I don't think even that is broad enough for what you're looking to do. You're going to have to override the rating.php templates to get all of that changed.woocommerce/templates/single-product/rating.php
if you're doing it on the single product page. if you're doing it in the loop then above filter should work fine, but here's the template location for that anywayswoocommerce/templates/loop/rating.php
To replace completely Stars rating on products without editing templates, use the following:
Code goes in function.php file of your active child theme (or active theme). Tested and works.