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:
(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?
source https://stackoverflow.com/questions/70353373/assign-woocommerce-custom-checkout-field-as-billing
Comments
Post a Comment