I am trying to modify the Woocomerce checkout page for orders that are failed or pending payment. On those orders the system comes to the checkout with an order already generated, but I am not able to retrieve the ID of that order from the form_checkout.php template.
Failed orders can be paid by the customer with the Woocommerce URL, similar to the following one:
https://myurl.com/checkout/order-pay/XXXXX/?pay_for_order=true&key=wc_order_XXXXXXXXXXXX&subscription_renewal=true
Neither do I retrieve the variables with a $_GET since the URL is transformed into https://myurl.com/checkout when accessing. I don’t know if you lose this data or where I can collect it.
Is this possible?
2
Answers
To retrieve the order Id on Order pay page you will use the following:
Note: To target Order pay page, you can use
is_wc_endpoint_url('order-pay')
conditional tag.$order = wc_get_order(get_query_var('order-pay'));