-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add name to Spree::Address #3458
Add name to Spree::Address #3458
Conversation
db38029
to
ce67527
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Filippo. I left some comments, let me know your thoughts.
Also, I've found this code into ActiveMerchant. Curious how they do the opposite to split the full name into different parts, do you prefer this way for a specific reason?
Still not sure about the Rubocop fixes merged in the PR. I'd love to keep them but these PRs are very critical and I'd focus their content on the changes only.
@kennyadsl Thanks for the feedback!
I just extracted the code used in
They seemed small enough to me but I can keep only the ones enforced by Hound to reduce changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filippoliverani thank you for working on this, I left some minor comments, I think this is a great start!
@spaghetticode Thank you for your feedback! |
ce67527
to
93da764
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filippoliverani thank you! Still one small nitpick, otherwise looks good to me 👍
52e2efd
to
3b59c0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much. This is a great change and very good work on the backwards compatibility 👏
I do think we should deprecate first_name
and last_name
as well.
Again, awesome work 🎉
@@ -163,7 +163,7 @@ def has_payment_profile? | |||
# the object to ActiveMerchant. | |||
# @return [String] the first name on this credit card | |||
def first_name | |||
name.to_s.split(/[[:space:]]/, 2)[0] | |||
Spree::Address::Name.new(name).first_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deprecate this method and move the logic into solidus_gateway
, respectively into the payment method extensions. Having ActiveMerchant related logic in core seems odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be part of another PR since there are also other (unrelated) methods that we should deprecate under the same motivation. I'd say to keep this as it's minimum since it's already an important/critical change.
@@ -172,7 +172,7 @@ def first_name | |||
# the object to ActiveMerchant. | |||
# @return [String] the last name on this credit card | |||
def last_name | |||
name.to_s.split(/[[:space:]]/, 2)[1] | |||
Spree::Address::Name.new(name).last_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto deprecate this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much. This is a great change and very good work on the backwards compatibility 👏
I do think we should deprecate
first_name
andlast_name
as well.Again, awesome work 🎉
Thank you @tvdeyen 🙏
The PR does not include deprecation yet to keep the amount of code changed at minimum. I was thinking to split the whole work into 4-5 PRs to ease the review work, this is a proposed roadmap #3234 (comment).
This is the first non-destructive step to have a unified name attribute. Spree::Name class is needed to perfortm the conversions that will ease the transition to name field.
The logic for splitting a name and concatenating name components should be centralized in a single class.
3b59c0c
to
8220390
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @filippoliverani. This is awesome!
Description
This PR proposes a first step to solve #3234 .
The main idea is to add a new
name
attribute toSpree::Address
and to deprecatefirstname
,lastname
andfull_name
usage while keeping full backward compatibility.This PR adds a virtual attribute
name
that replacesfull_name
and favors reading form it when accessing Address data. It uses aSpree::Address::Name
value object to handle name parsing during deprecation period.Checklist: