This is a request to revert a line that was part of this issue: #3072083
The line in question is:
commerce_order.module:330 (https://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/order...)
// Available countries are taken from the store.
$form['settings']['available_countries']['#access'] = FALSE;
The reasoning for the hiding of the available countries is clearly given in the comment, however, the available countries are only taken from the store for the address field used in the order form and not the field used in the customer profile (address book). While this may make the DX a little clearer for simple setups, it is a bad UX experience since the end user is allowed to create any address and is only later not allowed to use these addresses during checkout without any messaging to know why. Allowing the configuration of available countries for the address book field is needed.
- We need to account for the ability to have multiple "stores" with different configurations.
- Taking the store available countries list and applying them to the address book field is not easily possible because of item 1 above.
- Using the address module's available countries event is possible, however, that works globally for every address field in the site and so not an ideal situation.
- Removing the hiding of the field to allow the developer to set the allowed countries covers all use cases since the store configuration overrides what is set in the profile during checkout. If the site only has one store, the developer can set both fields to the same configuration to give a unified experience to the user. If the site has multiple store configurations, then the developer would need to make sure that the profile configuration was an inclusive set of the available countries across all stores. While this is many not be entirely obvious DX wise, I believe that UX trumps DX.
- That is not to say that DX is not important though, so what about adding a description help text instead of removing the available countries field configuration instead?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | allow-customer-profile-available-country-config-3125801-4.patch | 1.65 KB | dragonwize |
| #2 | allow-customer-profile-available-country-config-3125801-1.patch | 818 bytes | dragonwize |
Issue fork commerce-3125801
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dragonwize commentedComment #4
dragonwize commentedFixed test.
Comment #5
sajithathukorala commentedTested and worked fine ,
Comment #6
capysara commentedPatch works as expected and is very useful information.
Comment #7
matthiasm11 commented+1 for patch #4. Thanks!
Comment #8
damien laguerre commentedApplied the patch on Drupal 10.3.5 + commerce 2.40 and everything works fine.
Very useful, thank you!
Comment #9
anybodyCould someone please create a MR against 3.0.x from this? Thanks!
Comment #11
sorabh.v6Comment #13
sorabh.v6Created the MR -> https://git.drupalcode.org/project/commerce/-/merge_requests/635
Please review.