With Woocommerce, I would like see user meta data in admin order edit pages using woocommerce_localisation_address_formats
hook.
Based on "Woocommerce Edit order on admin dashboard" answer code, that I have lightly changed as follow:
add_filter( 'woocommerce_localisation_address_formats', 'admin_localisation_address_formats', 50, 1 );
function admin_localisation_address_formats( $address_formats ){
if( is_admin() ){
$address_formats = array();
$countries = array('default', 'AU', 'AT', 'BE', 'CA', 'CH', 'CL', 'CN', 'CZ',
'DE', 'EE', 'FI', 'DK', 'FR', 'HK', 'HU', 'IN', 'IS', 'IT', 'JP', 'TW', 'LI',
'NL', 'NZ', 'NO', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'TR', 'US', 'VN' );
foreach( $countries as $country_code ) {
$address_formats[$country_code] = "{company}
{name}
{address_1} {address_2} {postcode}
{city} {state}
{country}
{billing_nombrecontacto}";
}
}
return $address_formats;
}
Where {billing_nombrecontacto}
should be custom data to insert in admin order pages… But it doesn't make anything.
To add a billing_nombrecontacto
I have used the following code:
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields,$fields2)
{
$fields['billing_nombrecontacto'] = array(
'label' => __('Nombre de contacto', 'woocommerce'), // Add custom field label
'placeholder' => _x('Nombre de contacto', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
$fields['billing_cuit'] = array(
'label' => __('CUIT', 'woocommerce'), // Add custom field label
'placeholder' => _x('CUIT', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
$fields['billing_emaildelvendedor'] = array(
'label' => __('Email del Contacto', 'woocommerce'), // Add custom field label
'placeholder' => _x('email del Vendedor', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
$fields['billing_nombrecontacto']['priority'] = 102;
return $fields;
}
The data is collected correctly, I can see it in my account for this custom field.
How to make it work? I am stuck.