davbuc
davbuc

Reputation: 537

Pass Woocommerce Order ID into filter in functions.php

i want to add some additional information to the "order-completed"-Email in Woocommerce. I have tried several solutions but it seems that I just can't get the order-id.

What I tried for e.g.:

add_filter('woocommerce_email_heading_customer_completed_order','getWC_order_details');
function getWC_order_details( $order ) {
    $test = var_dump( $order->id );
    return $test;
}

Always getting NULL or bool(false), what am I missing here?

Upvotes: 1

Views: 753

Answers (1)

rnevius
rnevius

Reputation: 27112

As you can see in the source, that filter takes two parameters: (1) the heading text, (2) the order object. You must also explicitly specify that in your functions:

add_filter('woocommerce_email_heading_customer_completed_order','getWC_order_details', 10, 2);
function getWC_order_details( $heading, $order ) {
    $test = var_dump( $order->id );
    return $test;
}

Upvotes: 1

Related Questions