/** * @snippet Orders History @ WooCommerce Single Order Admin Page * @how-to businessbloomer.com/woocommerce-customization * @author Rodolfo Melogli, Business Bloomer * @compatible WooCommerce 9 * @community https://businessbloomer.com/club/ */ add_action( 'add_meta_boxes', function() { add_meta_box( 'order_history', 'Customer Order History', 'bbloomer_display_order_history', 'shop_order', 'normal', 'default' ); }, 1 ); function bbloomer_display_order_history() { global $post; $order = wc_get_order( $post->ID ); if ( ! $order ) return; $orders = array(); if ( $id = $order->get_customer_id() ) { $orders = wc_get_orders( [ 'customer_id' => $id, 'return' => 'ids', 'limit' => 10 ] ); } if ( ! $orders ) return; echo '
| ID | DATE | ITEMS | STATUS |
|---|---|---|---|
| ' . $order_id . ' | ' . wc_format_datetime( $order->get_date_created() ) . ' | ' . implode( ' | ', $items ) . ' | ' . $order->get_status() . ' |