Explicit Brand Design
Explicit Brand Design

Reputation: 158

How can I get the order id of a woocommerce order to use in a function in functions.php?

How can I get the order id of a woocommerce order to be used in a function in functions.php?

I would like to be able to check the id of the order(s) when at:

the woocommerce my account page (for each order): http://example.com/my-account

and

the woocommerce checkout page (for the current order): http://example.com/checkout/order-pay/210?pay_for_order=true&key=order_53df9a0e8116a

I know that on the check out page, the order id can be accessed through $order->id; in the form-pay.php template (located at plugins/woocommerce/templates/checkout/form-pay.php) I would like to be able to do the same from inside my theme's functions.php file.

Upvotes: 1

Views: 7186

Answers (1)

Explicit Brand Design
Explicit Brand Design

Reputation: 158

The answer is:
get_query_var('order-pay');

I found this by looking through var_dump($GLOBALS) - thanks to this.lau_'s suggestion

Upvotes: 4

Related Questions