I have following code
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'edit_woocommerce_order_page', 10, 1 );
function edit_woocommerce_order_page($order){
$customer_id = $order->get_user_id();
//Check if its guest or not
if($customer_id != 0):
$args = array(
'customer_id' => $customer_id,
);
$order_id = $order->get_id();
$orders = wc_get_orders( $args );
if($orders):
foreach($orders as $k=>$order):
echo '<strong>'.$order->get_id().' </strong>';
endforeach;
endif;
endif;
}
This code displays ID’s of orders by Customer. The main thing I need is just display current order ID and previous order ID. For example customer has a few orders with following ID’s 310, 300, 250, 200. When I go to order 250(as example), I’d like to see current order ID and order ID 200. So I don’t need to see 310, 300 and 200.
To get current order ID I use this code
$order_id = $order->get_id();
Any thoughts?:)
See screenshot how this code works