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 class="widefat" type="text" name="kral_product_name" id="kral_product_name" value="salaaaaaaaaaaaaam" />
</p>
<?php
}
My Answer:
To add a custom meta box for WooCommerce reviews, you can use the following code:
php
function kral_product_review_metabox() {
add_meta_box(
'kral_product_review',
'اطلاعات دیدگاه',
'kral_product_review_fields_metabox',
'product',
'normal',
'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');
// Add your custom fields here
}
In the `add_meta_box` function, make sure to change the post type from `'product-reviews'` to `'product'` as WooCommerce reviews are stored as comments on the product post type.
Inside the `kral_product_review_fields_metabox` function, you can add your custom fields using standard HTML input elements. Make sure to save the data using the `save_post` action hook.
Additionally, you can use the `get_comment_meta` and `update_comment_meta` functions to retrieve and update the custom meta data for the review.
Rate this post
4 of 5 based on 2761 votesComments