Hi,
Thank you for contacting us,
In short, custom fields will always display in predefined positions in both Order Details Page and Order Email.
In Order Details page, all custom fields will always be displayed along with ‘Customer Details’. And in Order Email, all custom fields will always be displayed just before ‘Your details’ section.
I hope I understood you question properly. Let us know in case you need more details.
Thanks,
Support-ThemeHigh
Hi Support-ThemeHigh,
Thank you for answering my question.
Is there any method that I can put billing_address_3 in “billing adress” section in the email?
I tried like this in function.php of my child theme:
add_filter( ‘woocommerce_order_formatted_billing_address’ , ‘my_default_address_fields’ );
function my_default_address_fields( $fields ) {
$fields2[‘address_1’] = $fields[‘billing_address_1’];
$fields2[‘address_2’] = $fields[‘billing_address_2’];
$fields2[‘address_3’] = $fields[‘billing_address_3’];
return $fields2;
}
But it doesn’t work. And I cannot find any solution on internet.
Can you please help me?
Thanks!!!
Hi,
I hope the below code will help you,
add_filter( ‘woocommerce_order_formatted_billing_address’ , ‘my_default_address_fields’, 10,2 );
function my_default_address_fields( $fields, $order ) {
$address_3 = get_post_meta( $order->id, ‘billing_address_3’, true ); // use your custom field name here(ex: billing_address_3)
$fields[‘address_3’] = $address_3;
return $fields;
}
add_filter( ‘woocommerce_formatted_address_replacements’, ‘add_new_replacement_fields’,10,2 );
function add_new_replacement_fields( $replacements, $address ) {
$replacements[‘{address_3}’] = isset($address[‘address_3’]) ? $address[‘address_3’] : ”;
return $replacements;
}
add_filter( ‘woocommerce_localisation_address_formats’, ‘my_address_formats’ );
function my_address_formats( $formats ) {
// Rearrange these fields how you need, each country has an entry in the array like this:
$formats[‘IN’] = “{name}\n{company}\n{address_1}\n{address_2}\n{address_3}\n{city}, {state} {postcode}\n{country}”;
return $formats;
}
Thanks,
Support-ThemeHigh
Hi Support-ThemeHigh,
Million times thank you
This is exactly what i needed. And it works perfectly.
Thanks!!!
Glad to hear that it worked for you!
We take this opportunity to request you to give your valuable review if you like our plugin.
I am closing this thread, please let us know in case you have any issue with our plugin.
Thanks,
Support-ThemeHigh