Woocommerce order_id on view order page as a variable

Want to get the order_id on the order page, for Woocommerce orders?

The process is so simple. Simply add the following function to your theme’s functions.php file, or use a custom plugin.

See how to create a custom plugin for more information.

function show_order_id_on_view_order_page ($order_id) {

                $order = wc_get_order($order_id);

                $order_id = $order->id;

                echo $order_id;

}

add_action(‘woocommerce_view_order’,’show_order_id_on_view_order_page’, 11);

This function may be useful, especially when you want to have some custom functionality on the view order, that depends on the order id.

For example, adding a support functionality on the view order page.

Share this