Home > Mobile >  how to add custom meta box for woocommerce review?
how to add custom meta box for woocommerce review?

Time:08-25

I want to show some information in woocommerce review edit section and I don't know how to put them in woocommerce review I tested this code in bottom but it doesn't work

function kral_product_review_metabox() {
    add_meta_box(
        'kral_product_review',
        'اطلاعات دیدگاه',
        'kral_product_review_fields_metabox',
        'product-reviews',
        'side',
        'high'
    );
}
add_action('add_meta_boxes', 'kral_product_review_metabox');

function kral_product_review_fields_metabox($post) {

    wp_nonce_field(basename(FILE), 'kral_product_review_nonce');

?>
    <p>
        <label for="kral_product_name">label</label>
        <br />
        <input  type="text" name="kral_product_name" id="kral_product_name" value="salaaaaaaaaaaaaam" />
    </p>
<?php
}

CodePudding user response:

You are using the wrong post type value as screen value and the wrong context value.

The correct screen name will be comment not product-reviews

WordPress Documentation says that you can use side as context value when adding meta boxes on the comments page but I am not sure why it doesn't work with the side value.

Correct add_meta_box code will look like this:

add_meta_box(
    'kral_product_review',
    'اطلاعات دیدگاه',
    'kral_product_review_fields_metabox',
    'comment',
    'normal',
);
  • Related