WC_Comments::update_comment_type()public staticWC 3.5.0

Update comment type of product reviews.

Method of the class: WC_Comments{}

No Hooks.

Return

Array.

Usage

$result = WC_Comments::update_comment_type( $comment_data );
$comment_data(array) (required)
Comment data.

Changelog

Since 3.5.0 Introduced.

WC_Comments::update_comment_type() code WC 9.3.3

public static function update_comment_type( $comment_data ) {
	if ( ! is_admin() && isset( $_POST['comment_post_ID'], $comment_data['comment_type'] ) && self::is_default_comment_type( $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok.
		$comment_data['comment_type'] = 'review';
	}

	return $comment_data;
}