diff --git a/src/StoreApi/Schemas/V1/ProductReviewSchema.php b/src/StoreApi/Schemas/V1/ProductReviewSchema.php index 6ed7da0fef8..29d62b55d42 100644 --- a/src/StoreApi/Schemas/V1/ProductReviewSchema.php +++ b/src/StoreApi/Schemas/V1/ProductReviewSchema.php @@ -159,8 +159,8 @@ public function get_properties() { * @return array */ public function get_item_response( $review ) { - $rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true ); - $data = [ + $rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true ); + return [ 'id' => (int) $review->comment_ID, 'date_created' => wc_rest_prepare_date_response( $review->comment_date ), 'formatted_date_created' => get_comment_date( 'F j, Y', $review->comment_ID ), @@ -175,7 +175,5 @@ public function get_item_response( $review ) { 'verified' => wc_review_is_from_verified_owner( $review->comment_ID ), 'reviewer_avatar_urls' => rest_get_avatar_urls( $review->comment_author_email ), ]; - - return $data; } }