I’m trying to add a new meta box on the woocommerce order page in the dashboard.
add_action( 'add_meta_boxes', 'add_meta_box_wrapper' );
function add_meta_box_wrapper() {
add_meta_box( 'custom_meta_box', __( 'Facture' ), 'metabox_content', 'shop_order', 'side', 'core');
}
function metabox_content() {
echo '<a>Test button</a>';
}
This is the code I tried, but it doesn’t seem work.
If I change the fourth parameter of the add_meta_box function to post, I can get it to display in the post edit page so the problem must be with the slug I’m using. I also tried changing that parameter to ‘wc-orders’ as well as changing the action hook to ‘add_meta_boxes_shop_order’ and ‘add_meta_boxes_wc-orders’ like some people suggest in other threads, but nothing seems to work.
Anyone has an idea?
2
Answers
This issue is related to the fact that High Performance Order Storage (HPOS) is enabled, so you need something a bit different to add a custom Metabox to admin orders:
Code goes in functions.php file of your child theme (or in a plugin). Tested and works with or without HPOS enabled.
Related documentation: High Performance Order Storage Upgrade Recipe Book
Related:
You code also do something like this: