How do I retrieve the order ID in WooCommerce?
The current way of accomplishing this is by using this function:
$order->get_id();
That should return the order id without "#".
In older versions of WooCommerce, you may need to access it as a property instead:
echo $order->id;
it worked. Just modified it
global $woocommerce, $post;
$order = new WC_Order($post->ID);
//to escape # from order id
$order_id = trim(str_replace('#', '', $order->get_order_number()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With