job.answiz.com
  • 4
Votes
name
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

I’m using this code in my functions.php file:

function custom_woocommerce_order($order_id) {
    if (!$order_id) {
        return;
    }

    $order = wc_get_order($order_id);
    $order->update_status('processing');
}

add_action('woocommerce_new_order', 'custom_woocommerce_order');

This code is working but it prevents new order email notifications from displaying ordered items.

  • 1
Reply Report
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.

  • 1
Reply Report

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();
}
  • 4
Reply Report