Skip to content

[4.x] Ability to limit the countries available for selection when editing an address#15711

Merged
brandonkelly merged 6 commits into4.13from
feature/add-get-country-list-method-for-addresses
Sep 26, 2024
Merged

[4.x] Ability to limit the countries available for selection when editing an address#15711
brandonkelly merged 6 commits into4.13from
feature/add-get-country-list-method-for-addresses

Conversation

@nfourtythree
Copy link
Copy Markdown
Contributor

Description

Some projects require the need to limit the list of countries available for selection.

This PR adds and event that, when triggered, can manipulate the countries return. This gives developers control over which are available to content authors.

In the changes I have updated instances where the code where we were calling the addressing libraries core method and replaced it with our own so we have the chance to trigger an event.

The instances replaced are those that end up with the list being shown to a content author.

The instances of a call to the library's getList() method that has not been changed relate to validation of the address element. This call is still there to validate against the entire list of possible countries.

Related issues

craftcms/commerce#3306

@nfourtythree nfourtythree self-assigned this Sep 10, 2024
Copy link
Copy Markdown
Contributor

@i-just i-just left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I would maybe just consider adding a bit more info to the comment for the new Addresses::EVENT_DEFINE_ADDRESS_COUNTRIES event around adding new countries/changing country codes. Just a short summary of what we talked about - if you want to add new countries, you will have to use DI and create your own country repository?

@nfourtythree nfourtythree requested a review from i-just September 24, 2024 11:08
@brandonkelly brandonkelly merged commit 1aec54b into 4.13 Sep 26, 2024
@brandonkelly brandonkelly deleted the feature/add-get-country-list-method-for-addresses branch September 26, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants