Finaly i found i use $wcdn->print->order_ids[0], to get order ID and manipulate into wcdn_address_invoice to display my specific fields
hmm, there is a better way:
– both filters return the $order
object. which means you can read the order id with $order->id
.
– you can add new items to the info part with wcdn_order_info_fields
. here the text from the faq:
How can I add some more fields to the order info section?
Use the wcdn_order_info_fields filter hook. It returns all the fields as array. Read the WooCommerce documentation to learn how you get custom checkout and order fields. Tip: To get custom meta field values you will most probably need the get_post_meta( $order->id, ‘your_meta_field_name’, true); function and of course the your_meta_field_name.
An example that adds a ‘VAT’ and ‘Customer Number’ field to the end of the list. Paste the code in the functions.php file of your theme:
function my_custom_order_fields( $fields, $order ) {
$new_fields = array();
if( get_post_meta( $order->id, 'your_meta_field_name', true ) ) {
$new_fields['your_meta_field_name'] = array(
'label' => 'VAT',
'value' => get_post_meta( $order->id, 'your_meta_field_name', true )
);
}
if( get_post_meta( $order->id, 'your_meta_field_name', true ) ) {
$new_fields['your_meta_field_name'] = array(
'label' => 'Customer Number',
'value' => get_post_meta( $order->id, 'your_meta_field_name', true )
);
}
return array_merge( $fields, $new_fields );
}
add_filter( 'wcdn_order_info_fields', 'my_custom_order_fields', 10, 2 );
Of course, but i need to add somes custom fields into filter “wcdn_address_invoice” and i can’t use wcdn_order_info_fields filter.
when i add_filter for wcdn_address_invoice and dump $order->id, i get nothing as value.
add_filter('wcdn_address_invoice','my_function');
function my_function($fields){
var_dump($order->id);
}
the wcdn_order_info_fields and wcdn_address_invoice filter function have 2 arguments!
add_filter('wcdn_address_invoice','my_function', 10, 2);
function my_function($address, $order){
var_dump($order->id);
return $address;
}
I understand my error now 🙂
Thanks a lot piffpaffpuff;