-
Notifications
You must be signed in to change notification settings - Fork 9.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
Fix #9924, prefill prefix and suffix in checkout shipping address #9925
Changes from 3 commits
6bf365f
8b8c2fe
ff2319e
95b1684
322c357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,20 +316,19 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi | |
protected function getDefaultValue($attributeCode) | ||
{ | ||
switch ($attributeCode) { | ||
case 'prefix': | ||
return $this->getDefaultPrefix(); | ||
case 'firstname': | ||
if ($this->getCustomer()) { | ||
return $this->getCustomer()->getFirstname(); | ||
} | ||
break; | ||
return $this->getDefaultFirstname(); | ||
case 'lastname': | ||
if ($this->getCustomer()) { | ||
return $this->getCustomer()->getLastname(); | ||
} | ||
break; | ||
return $this->getDefaultLastname(); | ||
case 'suffix': | ||
return $this->getDefaultSuffix(); | ||
case 'country_id': | ||
return $this->directoryHelper->getDefaultCountry(); | ||
default: | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
|
@@ -388,4 +387,36 @@ protected function orderCountryOptions(array $countryOptions) | |
} | ||
return array_merge($headOptions, $tailOptions); | ||
} | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
protected function getDefaultPrefix() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magento does not encourage usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know. Because of plugins right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we do not encourage inheritance-based API. So composition in favor of inheritance. It's easier to maintain and reuse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes of course. That makes sense. |
||
{ | ||
return $this->getCustomer() ? $this->getCustomer()->getPrefix() : null; | ||
} | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
protected function getDefaultFirstname() | ||
{ | ||
return $this->getCustomer() ? $this->getCustomer()->getFirstname() : null; | ||
} | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
protected function getDefaultLastname() | ||
{ | ||
return $this->getCustomer() ? $this->getCustomer()->getLastname() : null; | ||
} | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
protected function getDefaultSuffix() | ||
{ | ||
return $this->getCustomer() ? $this->getCustomer()->getSuffix() : null; | ||
} | ||
} |
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.
Wouldn't it be better if you return
null
straight away, at the beginning of the method in case where there is no customer? I guess it should reduce complexity that way, since you would not have to check for customer every time.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.
Hahaha, brilliant... I guess programming for 12 hours straight is not paying off ;)
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.
Correction,
$this->directoryHelper->getDefaultCountry()
doesn't need a customer. Let me draft up a commit.