Momo
Momo

Reputation: 3

$order_id earliest hook function before payment

I am writing a plugin for woocommerce which needs the order ID before the users go to paypal and pays. I tried to get this information with several hooking on actions but all the time I get that $order_id is nothing/0. It seems that I hooked it too early, before I could get this by global vairable.

Do somebody knows what is the earliest function I can use to hook and get the $order_id or at least before the redirection to paypal?

Thanks very much!!!

Upvotes: 0

Views: 389

Answers (1)

Domain
Domain

Reputation: 11808

Before placing order you can not get the order id, so you have to write your function after order is being placed, so for that you can add your action on any one of these hooks-

  1. do_action( 'woocommerce_thankyou', $order->id );
  2. do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id );

Upvotes: 1

Related Questions