I'm trying to get order number and order key (wc_order=xxx parameter) at checkout before redirect customer, but I'm not sure what to do. My code is below but it's not working:
add_action( 'template_redirect', 'ui_redirect' );
function ui_redirect(){
global $woocommerce;
//if the current page is the order received and if there's an order key
if (is_wc_endpoint_url( 'order-received' ) ) {
$order_key = wc_get_order_id_by_order_key( $_GET['key'] );
$order_id = wc_get_order( $order_id );
wp_redirect( 'redirection here with parameters');
exit;
}
}