It is possible to make it required to have a house/door number is the address line ? Because else people can add :
Gloucester Pl Marylebone, London W1U 6HU UK and that is not a correct address for what I need.
Ia m sure a lot of people need that too...

TIA

Comments

cbe243 created an issue. See original summary.

pancho’s picture

If you want the house number be required: are you sure there are no valid addresses without house number in the UK? At least in Germany, in some small hamlets, these exist. Apart from that, how do you know the entered data is valid? Furthermore, how about P.O. boxes?

I think you can't do a proper validation without actual street data. There's a free, open-source postcode API at https://postcodes.io. Additionally/alternatively you can use paid services such as Google, getAddress, PostCoder or Ideal. There's probably more - I just did a short Google lookup.

bojanz’s picture

Category: Feature request » Support request
Status: Active » Fixed

Pancho is right, you probably don't want to make that field required.

In any case, the usual way of collecting a house number is to repurpose address_line2.
See https://docs.drupalcommerce.org/commerce2/developer-guide/customers/addr... for an example

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

pieterdc’s picture

Thanks for that hint @bojanz
I also needed hook_commerce_inline_form_alter() to make the alterations work on eg. the checkout pane, instead of only on the profile pages.

giorgio79’s picture

"The usual way of collecting house number is repurposing a field"?

Hmm, house number is a pretty default element in any address...