• Hi, i write this code to hide comment box on product review

    function sv_wc_hide_comment_review( $comment_form ) {
    global $product;
    unset( $comment_form[‘comment_field’] );
    }
    add_filter( ‘woocommerce_product_review_comment_form’, ‘sv_wc_hide_comment_review’ );

    but the comment box still show in product review,, anyone could help?

    • This topic was modified 7 years, 2 months ago by rezhart.
Viewing 1 replies (of 1 total)
  • A filter must return a value.

    I couldn’t find that filter in the list of available filters at:
    https://docs.woocommerce.com/wc-apidocs/hook-docs.html
    The nearest filter is: woocommerce_product_review_comment_form_args
    so:

    function sv_wc_hide_comment_review( $comment_form ) {
      unset( $comment_form['comment_field'] );
      return $comment_form;
    }
    add_filter( 'woocommerce_product_review_comment_form_args', 'sv_wc_hide_comment_review' );

    Unfortunately, this removes the stars as well as the comment box, so consider not using a filter at all and using some custom css to hide the comment box:

    .comment-form-comment {
      display:none;
    }

    This way you get to keep the stars.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide product review comment form’ is closed to new replies.