Woocommerce: Get order id after checkout page

I have purchased the Woocommerce Subscriptions plugin and i want to be able to get the order ID in checkout page.
I want this, because when a subscription is about to end, an email with a payment link is sent to the customer and an order is automatically added. When customer clicks the link, it redirects to the checkout page in order to pay for the order.
I need the order ID to retrieve meta data from the specific order using some function like wc_get_order_item_meta().

Related posts

3 comments

  1. You can get it like this:

        global $wp;
        $order_id = $wp->query_vars['order-pay'];
        $order = new WC_Order( $order_id );
    
  2. Get an order at the checkout page, mmmm, don’t think an order exists at this point, only a cart.

Comments are closed.