admin管理员组文章数量:1122832
I'm using Woocommerce and I'm trying to get the total for each star rating using the post id (just like in the image below). Each rating is stored on my database as a number from 1 - 5 I just don't know how to go about retrieving the total count for each rating.
Any help will be greatly appreciated.
I'm using Woocommerce and I'm trying to get the total for each star rating using the post id (just like in the image below). Each rating is stored on my database as a number from 1 - 5 I just don't know how to go about retrieving the total count for each rating.
Any help will be greatly appreciated.
Share Improve this question asked Nov 20, 2017 at 17:45 ed_mdked_mdk 232 silver badges7 bronze badges 2- this is the standard Woocommerce rating ? or something else ? – Temani Afif Commented Nov 20, 2017 at 18:31
- I'm using standard woocommerce rating, however the image is from a plugin. – ed_mdk Commented Nov 20, 2017 at 19:03
1 Answer
Reset to default 4You can use the function get_rating_count()
by specifying on each call the value needed. For example :
global $product;
$rating_1 = $product->get_rating_count(1);
$rating_2 = $product->get_rating_count(2);
$rating_3 = $product->get_rating_count(3);
$rating_4 = $product->get_rating_count(4);
$rating_5 = $product->get_rating_count(5);
You can read more about the function
本文标签: woocommerce offtopicHow to get total count for each star rating
版权声明:本文标题:woocommerce offtopic - How to get total count for each star rating? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736297637a1930053.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论