Skip to content

Cannot relabel Built In address fields in checkout #2558

@joeyhoer

Description

@joeyhoer

In the admin UI, it's possible to change a "Built In" Address Field's Field Name value. Changing the Field Name in the admin would changes the field's label on the registration page and on the my account page, but it does change the label in checkout.

This is the line of code which (I believe) is the issue.

label={
    field.custom ? (
        field.label
    ) : (
        <TranslatedString id={LABEL[field.name]} />
    )
}

Built In fields are not custom, so the TranslatedString value of the LABEL[field.name] is returned.

Here, LABEL is defined as

const LABEL: AddressKeyMap = {
    address1: 'address.address_line_1_label',
    address2: 'address.address_line_2_label',
    city: 'address.city_label',
    company: 'address.company_name_label',
    countryCode: 'address.country_label',
    firstName: 'address.first_name_label',
    lastName: 'address.last_name_label',
    phone: 'address.phone_number_label',
    postalCode: 'address.postal_code_label',
    stateOrProvince: 'address.state_label',
    stateOrProvinceCode: 'address.state_label',
};

The TranslatedString value is then fetched from the translations file. Here, the phone number value will always return "Phone Number".

Essentially, checkout always returns a static value for the label that cannot be changed by the user.

I believe the solution is to use field.label rather than using the lookup to LABEL[field.name].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions