Customers have an extra field called billing_ean
as part of their billing address.
I\'m using the following code to load, edit, and save their EAN number fr
Try the following instead, where the field displayed in order edit pages and the value is saved to order meta data and user meta data…
Your revisited code:
add_action( 'woocommerce_admin_order_data_after_billing_address', 'customer_ean_edit' );
function customer_ean_edit( $order ){
$value = get_user_meta( $order->get_customer_id(), 'billing_eannr', true );
?>
'billing_eannr',
'label' => __('EAN nr.:', 'woocommerce'),
'placeholder' => '',
'value' => $value,
'wrapper_class' => 'form-field-wide'
) );
?>get_customer_id(), 'billing_eannr', sanitize_text_field( $_POST['billing_eannr'] ) );
}
}
Code goes in function.php file of the active child theme (or active theme). tested and works.