• Resolved agiftforconv

    (@agiftforconv)


    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?

Viewing 1 replies (of 1 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Wouldn’t it be easier to simply assign these Post IDs directly on the shortcode?

    For example:

    [site_reviews assigned_posts="622,623,624"]
    [site_reviews_form assigned_posts="622,623,624"]
    

    Alternatively, you could create categories for each grouped product and assign reviews to that category.

    If you really want to use the hooks, then please update Site Reviews to v5.17.7 and then see the updated documentation:

Viewing 1 replies (of 1 total)
  • The topic ‘Make WC Products Share Reviews’ is closed to new replies.