S
S
Serufim2017-02-13 16:02:55
PHP
Serufim, 2017-02-13 16:02:55

Which hook is responsible for sending the woocommerce review?

I want to send a letter to the user in the online store after he has sent a review about the product. What event is this, what is it called and how to process it correctly????

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2017-02-14
@wppanda5

same as in WordPress
WooCommerce reviews are trivial comments.
Accordingly
When adding a comment

add_action('wp_insert_comment', 'wpp_comment_inserted', 99, 2);

function wpp_comment_inserted($comment_id, $comment_object) {
    //$comment_object - объект комментария, 
    //получаете пост на который он оставлен
    // и если это продукт отправляете письмо
}

When a comment is approved
add_action('transition_comment_status', 'wpp_comment_approve', 10, 3);

function wpp_comment_approve($new_status, $old_status, $comment_object) {
    if( $old_status !== $new_status && $new_status === 'approved' ) {
        //$comment_object - объект комментария,
       //получаете пост на который он оставлен
       // и если это продукт отправляете письмо
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question