Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    Hi,
    Thank you for contacting us,

    Custom fields will always be displayed 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.

    Below example code can be used to display custom fields as part of address.

    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;
    }

    Regards,
    Support-ThemeHigh

    Plugin Author ThemeHigh

    (@themehigh)

    Hope the above solution worked for you.
    We are closing this thread. Please let us know in case any issues

    Regards,
    Support-ThemeHigh

    Thread Starter Maha Dev

    (@mahadevnextgei)

    I tried your above code but nothing happens.

    Plugin Author ThemeHigh

    (@themehigh)

    Hi Maha Dev,

    We have tried this code again in our testing environment and working as expected.

    Please double confirm the field name you entered. Also make sure that you have used the correct country code in $format (in the above example it is IN for India ie, $formats[‘IN’] )

    Thread Starter Maha Dev

    (@mahadevnextgei)

    Hi, i have nothing to do with country. I tried your code again. field name is same as i am using. Actually your filters are not working, even not getting inside the function. I have used this code, now full name appears but still not in customer details.

    add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');
    
    function my_woocommerce_email_order_meta_keys( $keys ) {
    	$keys['Fullname'] = 'billing_full_name';
    	return $keys;
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Added a field fullname but not coming with customer details in email’ is closed to new replies.