How to get Order key for creating custom order return url in WooCommerce
This is the code that I am using to get a custom Order return URL: global $woocommerce; $test_order = new WC_Order($order_id); $test_order_key = $test_order->order_key; $returnURL = site_url().'/checkout/order-received/7140/'.$test_order_key; The example URL that I need is: http://www.example.com/checkout/order-received/[order_number]/key=[wc-order-key] How do I get [wc-order-key] ? Thanks. There is 2 ways to get the order key: 1) From an instance of WC_Order object class using the method get_order_key() , this way: // Get an instance of the WC_Order object $order_obj = WC_get_order($order_id)