0

I've created WooCommerce checkout custom fields via plugin that edit checkout fields.

So far it works, but I can't figure out how to display the custom fields in "Billing" under WooCommerce -> Orders: Billing

(This is important to my shipping plugin, that is why I insist it will be in billing section).

add_action( 'woocommerce_before_order_notes', 'bbloomer_add_custom_checkout_field' );
  
function bbloomer_add_custom_checkout_field( $checkout ) { 
   $current_user = wp_get_current_user();
   $saved_license_no = $current_user->license_no;
   woocommerce_form_field( 'license_no', array(        
      'type' => 'text',        
      'class' => array( 'form-row-wide' ),        
      'label' => 'License Number',        
      'placeholder' => 'CA12345678',        
      'required' => true,        
      'default' => $saved_license_no,        
   ), $checkout->get_value( 'license_no' ) ); 
}

I have this code that creates field.

How can I assign the custom field to Billing section?

Yotam Dahan
  • 635
  • 1
  • 8
  • 27
  • There is a `woocommerce_admin_billing_fields` filter you can use to modify the default admin billing fields of an order. Take a look at the woocommerce core: https://github.com/woocommerce/woocommerce/blob/5.9.0/includes/admin/meta-boxes/class-wc-meta-box-order-data.php#L42. – mfink Dec 14 '21 at 19:25

0 Answers0