Add optional `first_name` to `Spree::Address` behind a configuration flag
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5.3k
- Forks
- 1.4k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 62
Description
Background
Solidus 3.0 collapsed firstname/lastname on Spree::Address into a single name column (#3234). That remains the right default, but some stores (notably in EU markets, see #6110) need a separate given name for e-invoicing and for third-party services that require split names. Some stores use solidus_address_name or your their own customizations to extract names from addresses.
#6159 attempted to bring split names back into core, and the discussion there produced a design the core team agreed on. That PR has gone stale, so this issue captures the agreed design so a fresh PR can be written against it.
Agreed upon design
- Reintroduce
first_nameonly. The existingnamecolumn stays and doubles as the last name when the feature is enabled. We do not reintroducelastname. - Control the feature with a
Spree::Configpreference that defaults to the current unified approach. Stores that continue to use a single name field must see no change in behaviour at all. first_nameis optional by default. Stores can add a validation to require if need be, but let's all remember the Falsehoods Programmers Believe About Names.- If a store enables the flag, existing
namevalues are left untouched andfirst_nameis simply empty until filled in. - Backwards compatible for existing stores. The
firstnamecolumn still exists in the schema. Whether we reuse it (and un-ignore it) or add a newfirst_namecolumn can be decided in the PR, but any change must not require action from stores that leave the flag off.
Out of scope
- Any data migration between single and split names. Stores that switch modes are responsible for their own data.
Related
- #6159 (previous attempt, closed in favour of this issue)
- #6110 (compliance issue that motivated it)
- #3234 (original RFC to remove
firstname/lastname)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Spree::Address and Spree::Config implementations, then inspect the existing schema and related tests around address names. Implement the agreed configuration flag without changing the default behavior; with the flag enabled, first_name should be optional while existing name values remain untouched, and stores with the flag off should require no action.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100