Edit comment_post_ID on Review, Woocommerce


Here’s the scenario: I have a product X. I have created 2 products, Y and Z, where Y is two units of X and Z is 4 units of X. Now, when customers buy Y or Z, they will make a review for Y and Z. What I want is to programmatically change the reviews from Y and Z to X, because in the end, it’s just X that I sell. I use Cusrev plugin (https://wordpress.org/plugins/customer-reviews-woocommerce/).
So far I’ve tried:

function update_post_id_if_review($comment_id, $comment_object) {   
    // Get the post's ID
    $post_id = $comment_object->comment_post_ID;
    if ($post_id === BUNDLE_ID) {
        // Form an array of data to be updated
        $commentarr = array();
        $commentarr['comment_ID'] = $comment_id;
        $commentarr['comment_post_ID'] = MAIN_PRODUCT_ID;
        wp_update_comment( $commentarr );   

But it’s not working.

Any ideas?


Saulo Faria 3 months 0 Answers 16 views 0

Leave an answer