WC_Comments::add_comment_purchase_verification
Determine if a review is from a verified owner at submission.
Method of the class: WC_Comments{}
No Hooks.
Returns
true|false.
Usage
$result = WC_Comments::add_comment_purchase_verification( $comment_id );
- $comment_id(int) (required)
- Comment ID.
WC_Comments::add_comment_purchase_verification() WC Comments::add comment purchase verification code WC 10.5.0
public static function add_comment_purchase_verification( $comment_id ) {
$comment = get_comment( $comment_id );
$verified = false;
if ( 'product' === get_post_type( $comment->comment_post_ID ) ) {
// When possible, narrow down wc_customer_bought_product inputs for better performance.
$email = $comment->user_id ? '' : $comment->comment_author_email;
$verified = wc_customer_bought_product( $email, $comment->user_id, $comment->comment_post_ID );
add_comment_meta( $comment_id, 'verified', (int) $verified, true );
}
return $verified;
}