Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce remove meta boxes

Tags:

woocommerce

I want to remove some meta boxes like:

Product Short description, Reviews

I can remove default metaboxes:

function remove_metaboxes() {
     remove_meta_box( 'postcustom' , 'product' , 'normal' );
     remove_meta_box( 'postexcerpt' , 'product' , 'normal' );
     remove_meta_box( 'commentsdiv' , 'product' , 'normal' );
     remove_meta_box( 'tagsdiv-product_tag' , 'product' , 'normal' );
}
add_action( 'admin_menu' , 'remove_metaboxes' );

But I cant remove "postexcerpt" - Product Short description and "commentsdiv" - Reviews, because they are loaded in add_filter - add_meta_boxes

Is there any other hook after this to apply my script ? Or maybe there is another method ?

Thank you!

like image 258
andys Avatar asked Dec 20 '22 18:12

andys


1 Answers

WooCommerce removes the default postexcerpts and replaces it with its own version (the 'Product Short Description' meta box) (class-wc-admin-meta-boxes.php)

So like user1139767 said, you have to alter the priority. However when I tried 11, it didn't work, neither did 20. But 50 seems to do the trick:

function remove_metaboxes() {
     remove_meta_box( 'postcustom' , 'product' , 'normal' );
     remove_meta_box( 'postexcerpt' , 'product' , 'normal' );
     remove_meta_box( 'commentsdiv' , 'product' , 'normal' );
     remove_meta_box( 'tagsdiv-product_tag' , 'product' , 'normal' );
}
add_action( 'add_meta_boxes' , 'remove_metaboxes', 50 );
like image 58
Sam Turner Avatar answered Jan 22 '23 06:01

Sam Turner