I'm Dutch and in The Netherlands we use a different address format than in the US. We'd have to spit the street name and the house number. In order to fix that I used "address line 1" for 'Street name' and added a new custom checkout field called "house number". When a user orders something everything works fine at checkout. But in the WordPress/Woocommerce admin I'm having difficulties.

When I'm viewing an order everything looks fine. That's because I have a new address format:

add_filter( 'woocommerce_localisation_address_formats', 'new_address_formats' );

function new_address_formats( $formats ) {
    $formats['NL'] = "{name}\n{company}\n{address_1} {billing_house_number} {shipping_house_number}\n{postcode} {city}\n{country}";
    return $formats;

Overview address WooCommerce back-end/admin

But the problem comes when I click on the "edit address" icon. Address line 1 isn't called 'Street name', the House Number field isn't present at all and Address line 2 needs to be unset:

Current situation

In order to be able to edit the given House Number I added a custom function in my functions.php:

function editable_order_meta_shipping( $order ){

$house_number = get_post_meta( $order->get_id(), '_shipping_house_number', true );
<div class="address">
    <p<?php if ( empty($house_number) ) echo ' class="none_set"' ?>>
        <strong>House number:</strong>
        <?php echo ( !empty( $house_number ) ) ? $house_number : 'unknown' ?>
<div class="edit_address"><?php
    woocommerce_wp_text_input( array( 
        'id' => '_shipping_house_number',
        'label' => 'House number', 
        'wrapper_class' => 'form-field',
        'class' => '_shipping_house_number',
        'value' => $house_number
    ) ); ?>

add_action( 'woocommerce_admin_order_data_after_shipping_address', 'editable_order_meta_shipping' );

function save_shipping_details( $ord_id ){
    update_post_meta( $ord_id, '_shipping_house_number', wc_clean( $_POST[ '_shipping_house_number' ] ) );
add_action( 'woocommerce_process_shop_order_meta', 'save_shipping_details' );

This adds a field with "House number" that's editable:

Overview address after custom code at back-end

But I'm not able to find a solution to rename "Address line 1" label, to remove "Address line 2" completely and to reorder the fields so that "House number" is next to the "Address Line 1/Street Name" field.

Current situation:

enter image description here

What I would like to have:

enter image description here

Are you able to help/come up with a solution?

Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.