Transfer order data to woocommerce_checkout_order_processed

add_action('woocommerce_checkout_order_processed', 'send_order_fax');

function send_order_fax($order_id) {
    print_r($_REQUEST);
    die();
}

I want to capture the order ID or order details when this hook is triggered so that I can generate a fax. But it only sends form data. How can I get the order id so that I can get other things through functions.

thank

+4
source share
2 answers

You can get order information using the following code:

add_action('woocommerce_checkout_order_processed', 'send_order_fax');

function send_order_fax($order_id) {
    $order = new WC_Order( $order_id );
    $items = $order->get_items();
    print_r($items);
    die();
}
+6
source

in response to this:

Well, what else can I grab? - Rachel Khan

if you use var_dump ($ order); You will see all the information that the object holds.

Edit:

payment method:

get_post_meta( $order->id, '_payment_method', true )
0
source

All Articles