Make WC Products Share Reviews
-
Hi there!
I want multiple WooCommerce products to share reviews, ideally displaying a star rating in the archive etc.
For example, if someone leaves a review on WC Post ID 622, I want that review to appear for 622, 623 and 624.
It seems to work to set a review’s “assigned posts” to all the relevant pages manually after the review is created, so I’m trying to change the assigned posts of reviews using Hooks. If anyone has any ideas for a different way to do this, please let me know! I’m new to all this.
If you would also use hooks, my method isn’t working and it’s not clear to me why.
I’ve tried to change the ‘assigned_posts’ array, inspired by the “hiding the IP address” example from the Site Reviews FAQ:
add_filter('site-reviews/create/review-values', function ($values) { $values['assigned_posts'] = array(622,623,624); glsr_log($values); return $values; });
If a review is submitted on post id 622, this shows the change to $values[‘assigned_posts’] in the log (which is too long to post here), but doesn’t actually change anything in the review.
Also within the $values[] array is a ‘request’ array which contains another ‘assigned_posts’ array – I tried changing this too but still nothing changed in the review.
I even changed the post_id from 622 to 623 to see if the review changed which page it was for, but even that made no difference to the review. At the end of all tests, the assigned post was still just 622.
What am I missing? Any other ideas? Any completely different ways to do this?
- The topic ‘Make WC Products Share Reviews’ is closed to new replies.