Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grab order details in hook 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 grab the order id or order details when this hooks fire so that i can generate a fax. But it is only sending the form data. How can i get the order id so that i can fetch other things via functions.

Thanks

like image 689
Raheel Avatar asked Nov 03 '14 12:11

Raheel


2 Answers

You can get order details using 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();
}
like image 106
Bhumi Shah Avatar answered Sep 27 '22 23:09

Bhumi Shah


in reply to this:

nice , what other things i can grab ? – Raheel Khan

if you use var_dump( $order ); you will see all the information the object is holding.

Edit:

payment method:

get_post_meta( $order->id, '_payment_method', true )
like image 45
belfort1 Avatar answered Sep 27 '22 21:09

belfort1