Passing Order ID to a hook
-
I have a recurring issue in my WooCommerce customizations: getting the current order id inside a function.
For example, in the context of a user’s account page for a specific order, the following doesn’t work.
The problem is that
$order_id
is empty, of course. But how would I get the ID of the order into this function?add_action( 'woocommerce_order_items_table', 'xcsn_woocommerce_order_items_table'); function xcsn_woocommerce_order_items_table ( $order_id ) { $order = new WC_Order( $order_id ); echo 'The order ID is: ' . $order->get_order_number(); // or echo '<br>The order ID is: ' . $order->id; }
The code is stored in functions.php or my plugin – it doesn’t matter.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Passing Order ID to a hook’ is closed to new replies.