Adding a custom billing email field
-
Thanks for this wonderfull plugin!
I had the problem, that I use a custom field in the checkout where users can enter an additional e-mail address for their billing departement. Problem was, that I wasn’t aware that it needs to start with billing_ and that it didn’t show up in the users profile after creating or syncing the profil within a order. Chat GPT hepled me to create the following script and it seems to work. I thought I post it in case others are struggling as well. Hope it is correct otherwise please correct! 😉/**
* Add custom billing field to the order edit screen and user profile in backend.
*/
add_filter('woocommerce_admin_billing_fields', 'order_admin_custom_fields');
function order_admin_custom_fields($fields)
{
global $the_order;
$fields['invoice_email'] = array(
'label' => __( 'Invoice Email', 'woocommerce' ),
'show' => true, // shows field in the order billing box
);
return $fields;
}
add_filter('woocommerce_customer_meta_fields', function($fields) {
if ( isset($fields['billing']['fields']) ) {
$fields['billing']['fields']['billing_invoice_email'] = array(
'label' => __('Invoice Email', 'woocommerce'),
'description' => __('Additional email address for invoices', 'woocommerce'),
'type' => 'email',
'custom' => true,
);
}
return $fields;
});
Best regards, Fletsch
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Adding a custom billing email field’ is closed to new replies.