diff --git a/assets/php/class-wgpb-block-reviews-by-product.php b/assets/php/class-wgpb-block-reviews-by-product.php
index 876e20eb785..13ceb498ac5 100644
--- a/assets/php/class-wgpb-block-reviews-by-product.php
+++ b/assets/php/class-wgpb-block-reviews-by-product.php
@@ -57,6 +57,36 @@ protected function parse_attributes( $attributes ) {
return $attributes;
}
+ /**
+ * Render the Reviews by Product meta (author and date).
+ *
+ * @param array $comment Comment attributes.
+ */
+ public function reviews_display_meta( $comment ) {
+ $verified = wc_review_is_from_verified_owner( $comment->comment_ID );
+
+ if ( ! $this->attributes['showReviewerName'] && ! $this->attributes['showReviewDate'] ) {
+ return;
+ }
+
+ $html = '
';
+ if ( $this->attributes['showReviewerName'] ) {
+ $html .= '' . get_comment_author() . '';
+ if ( 'yes' === get_option( 'woocommerce_review_rating_verification_label' ) && $verified ) {
+ $html .= '(' . esc_attr__( 'verified owner', 'woo-gutenberg-products-block' ) . ') ';
+ }
+ }
+ if ( $this->attributes['showReviewerName'] && $this->attributes['showReviewDate'] ) {
+ $html .= '–';
+ }
+ if ( $this->attributes['showReviewDate'] ) {
+ $html .= '';
+ }
+ $html .= '
';
+
+ echo esc_attr( $html );
+ }
+
/**
* Render the Reviews by Product.
*
@@ -85,7 +115,23 @@ public function render() {
'callback' => 'woocommerce_comments',
'echo' => false,
);
-
- return '';
+ remove_action( 'woocommerce_review_meta', 'woocommerce_review_display_meta', 10 );
+ add_action( 'woocommerce_review_meta', array( $this, 'reviews_display_meta' ), 10 );
+ if ( ! $this->attributes['showProductRating'] ) {
+ remove_action( 'woocommerce_review_before_comment_meta', 'woocommerce_review_display_rating', 10 );
+ }
+ if ( ! $this->attributes['showReviewerPicture'] ) {
+ remove_action( 'woocommerce_review_before', 'woocommerce_review_display_gravatar', 10 );
+ }
+ $list_comments = wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', $args ), $comments );
+ add_action( 'woocommerce_review_meta', 'woocommerce_review_display_meta', 10 );
+ remove_action( 'woocommerce_review_meta', array( $this, 'reviews_display_meta' ), 10 );
+ if ( ! $this->attributes['showProductRating'] ) {
+ add_action( 'woocommerce_review_before_comment_meta', 'woocommerce_review_display_rating', 10 );
+ }
+ if ( ! $this->attributes['showReviewerPicture'] ) {
+ add_action( 'woocommerce_review_before', 'woocommerce_review_display_gravatar', 10 );
+ }
+ return '';
}
}