How to add a custom field on WooCommerce reviews form?
Question
i have 2 problems with my code.
1. i can see only the title in the comments. cant see the cons.
2. how do i make the con’s part to have a title “cons” and then the text that the user wrote. as oppose to the title that just shows the title the user wrote.
add_action( 'comment_post', 'save_comment_review_title_field' );
function save_comment_review_title_field( $comment_id ){
if( isset( $_POST['title'] ) )
update_comment_meta( $comment_id, 'title', esc_attr( $_POST['title' ] ) );
}
function add_review_title_field_on_comment_form() {
echo '<p class="comment-form-title uk-margin-top"><label for="title">' . __( 'כותרת', 'text-domain' ) . '</label><input class="uk-input uk-width-large uk-display-block" type="text" name="title" id="title"/>
<label for="Cons">' . __( 'cons', 'text-domain' ) . '</label><textarea rows="3", cols="50", placeholder="placeholder" <input class="uk-input uk-width-large uk-display-block" type="text" name="Cons" id="Cons"/></textarea></p>';
}
add_action( 'comment_form_logged_in_after', 'add_review_title_field_on_comment_form' );
add_action( 'comment_form_after_fields', 'add_review_title_field_on_comment_form' );
function get_review_title( $id ) {
$val = get_comment_meta( $id, "title", true );
$title = $val ? '<strong class="review-title">' . $val . '</strong>' : '';
return $title;
0
comments, custom-field, woocommerce
3 years
2019-10-31T05:26:01-05:00
2019-10-31T05:26:01-05:00 0 Answers
75 views
0
Leave an answer