When you edit an order as an admin, you’re presented with the usual WooCommerce layout: order details on the left, order action on the right, the list of order items on the bottom left, and – possibly – additional meta boxes added by third party plugins (e.g. the PDF Invoice and Packing List plugin order meta box where you can define the invoice date and number).
On top of that, it’s also possible, of course, to define our own custom meta boxes, so that the administrator and/or shop managers can view (or even enter) additional information.
I’ve used it on a client website to show a custom field, but you can print anything you wish – even documentation for shop managers (how to complete the order for example).
So, here’s how we add a new “section” (meta box) to the single order edit page in the WordPress dashboard, and how we display some content in it. Enjoy!
PHP Snippet: Custom Meta Box @ WooCommerce Edit Order Page
/**
* @snippet Add Meta Box @ WooCommerce Edit Order
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 7
* @community https://businessbloomer.com/club/
*/
add_action( 'add_meta_boxes', 'bbloomer_order_meta_box' );
function bbloomer_order_meta_box() {
add_meta_box( 'custom_box', 'Custom Box', 'bbloomer_single_order_meta_box', 'shop_order', 'advanced', 'high' );
}
function bbloomer_single_order_meta_box() {
// global $post; // OPTIONALLY USE TO ACCESS ORDER POST
echo 'Whatever HTML content';
}
This snippet not working…
Works for me! What error do you get?
Nothing error.
just no new block is created…
Tried it again, it still works. Must be something else
i tried, but again not work…
Maybe your theme (or another plugin) is messing/conflicting with my snippet.
To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentytwenty” theme (load the snippet there in functions.php) as explained here: https://www.businessbloomer.com/lesson/trwm4l01/
Once you do that, does it work? If yes, you have a problem with your current theme or one of the plugins.
Hope this helps!
all problem is from HPOS, when woocommerce is in HPOS, then replace screen from function: ‘shop_order’ with ‘woocommerce_page_wc-orders’
Interesting, thank you – didn’t know that!
This was working for a long time , after an update when i clicked the button this didnt work.It’s not even loading the page ,i mean the button doing nothing.Can you help please?
Which button, Dimos?
Dimos probably set woocommerce to HPOS , and it doesnt work with that