How to Enable All Product Reviews in WooCommerce using bulk edit
If you want to enable product reviews for all your products in WooCommerce, instead of manually ticking the “Enable reviews” option for each product, you can use the following code:
add_action( 'woocommerce_product_bulk_edit_end', 'wcerbe_woocommerce_product_bulk_edit_end' );
function wcerbe_woocommerce_product_bulk_edit_end() {
$output = '' . esc_html__( "Enable reviews", "woocommerce" ) . '?';
$output .= '<select name="_reviews_allowed">';
$options = array(
'' => __( '— no change —', 'woocommerce' ),
'yes' => __( 'yes', 'woocommerce' ),
'no' => __( 'no', 'woocommerce' ),
);
foreach ( $options as $key => $value ) {
$output .= '<option value="' . esc_attr( $key ) . '">' . esc_html( $value ) . '</option>';
}
$output .= '</select>';
echo $output;
}
add_action( 'woocommerce_product_bulk_edit_save', 'wcerbe_woocommerce_product_bulk_edit_save', 10, 1 );
function wcerbe_woocommerce_product_bulk_edit_save( $product ) {
// enable reviews
if ( ! empty( $_REQUEST['_reviews_allowed'] ) ) {
if ( 'yes' === $_REQUEST['_reviews_allowed'] ) {
$product->set_reviews_allowed( 'yes' );
} else {
$product->set_reviews_allowed( '' );
}
}
$product->save();
}
To enable all product reviews, you need to add this code to your theme’s functions.php file or use a custom plugin. This code adds a new option in the bulk edit section of WooCommerce products. When you select this option and save the changes, it will enable reviews for all the selected products.
Please note that modifying code should be done carefully, and it’s recommended to backup your website before making any changes.