I am trying to get wooCommerce order id. I wrote the following script in functions.php but i getting 0.Can you tell how to get the Id.
global $woocommerce, $post;
$order = new WC_Order($post->ID);
$order_id=$order->get_id();
I am trying to get wooCommerce order id. I wrote the following script in functions.php but i getting 0.Can you tell how to get the Id.
global $woocommerce, $post;
$order = new WC_Order($post->ID);
$order_id=$order->get_id();
2
Answers
You can get order id by this function.
get_order_number()
You can use the code given below.
You can check additional documentation from this link.
Let me know if it works for you.
Have you tried this ?
How you are calling the above code(like hook) in functions.php…