Add custom field to invoice
-
Hi,
I want to add a custom field that I’ve created with a third party plugin, and the Key_meta_data is billing_wooccm12, it’s an ID. I followed your instructions but nothing is shown in the invoice, not even the label. I added this code at the end of the theme functions.php file. I’m using Astra theme, and the plugin I used to create the custom field is “WooCommerce Checkout Manager”. What am I doing wrong?
Also I have to mention that this field is only shown if a previous question is answered Yes. But in this case the order that I used to do my test the answer was yes and the field was fulfilled, but no data was shown in the invoice.
function example_custom_order_fields( $fields, $order ) { $new_fields = array(); if( get_post_meta( $order->id, 'billing_wooccm12', true ) ) { $new_fields['billing_wooccm12'] = array( 'label' => 'ID:', 'value' => get_post_meta( $order->id, 'billing_wooccm12', true ) ); } return array_merge( $fields, $new_fields ); } add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add custom field to invoice’ is closed to new replies.