I'm building a WooCommerce website that has a custom review system. I want to show the same reviews for multiple products that are variations but have their own product page.
Still I want to be able to sort products based on their rating, so I want to programmatically update '_wc_average_rating' whenever a custom review is placed. Also the rich data markup is using these fields to populate the rich data markup.
I'm using the following code to update the meta values.
update_post_meta( 13566, '_wc_review_count', 4);
update_post_meta( 13566, '_wc_rating_count', 4);
update_post_meta( 13566, '_wc_average_rating', 5.00);
For the review and rating count it is working fine, but for the average rating it's not working.
I tried different things, like:
update_post_meta( 13566, '_wc_average_rating', 5.00);
update_post_meta( 13566, '_wc_average_rating', 5);
update_post_meta( 13566, '_wc_average_rating', '5.00');
How can I update the _wc_average_rating meta field? Is there a function to do this?
Thanks so much!
