add_filter( 'woocommerce_checkout_fields' , 'checkout_address_details_fields' ); function checkout_address_details_fields( $fields ) { $fields['billing']['ct_invoice_taxid'] = array( 'label' => __('USt-Identifikationsnummer', 'woocommerce'), 'placeholder' => '', 'required' => false, 'class' => array('form-row-wide'), 'clear' => true, 'priority' => 35, ); return $fields; } add_action( 'woocommerce_checkout_update_order_meta', 'ct_invoice_save_fields' ); function ct_invoice_save_fields( $order_id ) { if ( ! empty( $_POST['ct_invoice_taxid'] ) ) { update_post_meta( $order_id, 'ct_invoice_taxid', sanitize_text_field( $_POST['ct_invoice_taxid'] ) ); } } add_action( 'woocommerce_admin_order_data_after_billing_address', 'ct_custom_checkout_field_display_admin_order_meta', 10, 1 ); function ct_custom_checkout_field_display_admin_order_meta($order){ $taxid = get_post_meta( $order->get_id(), 'ct_invoice_taxid', true ); if(!empty($taxid)){ echo '<div class="clear"></div>'; echo '<p>USt-Identifikationsnummer: '; echo '<span>'. $taxid . '</span>'; echo '</p>'; } } add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 ); function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) { $fields['ct_invoice_taxid'] = array( 'label' => __( 'USt-Identifikationsnummer' ), 'value' => get_post_meta( $order->id, 'ct_invoice_taxid', true ), ); return $fields; }