Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: 4.13
Choose a base branch
from

Conversation

nfourtythree
Copy link
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

Copy link
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?

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.

2 participants