-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Admin Order - Email is Now Required - Magento 2.3 #22648
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
Changes from all commits
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 |
---|---|---|
|
@@ -39,6 +39,8 @@ class Account extends AbstractForm | |
*/ | ||
protected $_extensibleDataObjectConverter; | ||
|
||
const XML_PATH_EMAIL_REQUIRED_CREATE_ORDER = 'customer/create_account/email_required_create_order'; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Backend\Model\Session\Quote $sessionQuote | ||
|
@@ -147,7 +149,7 @@ protected function _addAdditionalFormElementData(AbstractElement $element) | |
{ | ||
switch ($element->getId()) { | ||
case 'email': | ||
$element->setRequired(1); | ||
$element->setRequired($this->isEmailRequiredCreateOrder()); | ||
$element->setClass('validate-email admin__control-text'); | ||
break; | ||
} | ||
|
@@ -204,4 +206,17 @@ private function extractValuesFromAttributes(array $attributes): array | |
|
||
return $formValues; | ||
} | ||
|
||
/** | ||
* Retrieve email is required field for admin order creation | ||
* | ||
* @return bool | ||
*/ | ||
public function isEmailRequiredCreateOrder() | ||
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. Please, make method private |
||
{ | ||
return $this->_scopeConfig->getValue( | ||
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ | |
*/ | ||
const XML_PATH_DEFAULT_EMAIL_DOMAIN = 'customer/create_account/email_domain'; | ||
|
||
const XML_PATH_EMAIL_REQUIRED_CREATE_ORDER = 'customer/create_account/email_required_create_order'; | ||
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. Please, make constant private 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. Judging by the current code not obeying such practice I would suggest that change be made in a separate PR aimed at resolving this in the entire class. 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. Having said that - I notice the PHPDOC is missing for this constant. 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. @driskell we can't make existing constants as private due to backward compatibility, but the new one should be private. |
||
/** | ||
* Quote session object | ||
* | ||
|
@@ -2029,7 +2030,30 @@ protected function _validate() | |
*/ | ||
protected function _getNewCustomerEmail() | ||
{ | ||
return $this->getData('account/email'); | ||
$email_required = $this->_scopeConfig->getValue( | ||
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. Please, avoid underscore in the variable naming 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. As above, this isn’t obeyed by the remaining code and likely require refactor of unrelated code, and so would increase scope of the PR. I’d suggest to pick this up in a separate PR that resolves this for all properties in the class. 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. @driskell it's not a big deal to rename variables in the modern IDE, it requires an additional commit to make code style better. 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. Could it be a problem that it is protected and not private? I worry further change here might delay the PR merge due to unrelated opportunistic change. As it stands I’m happy to help with the other changes but this one feels like it needs a little more thought and a separately considered and reversible changeset so this feature isn’t lost should an issue be raised. |
||
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
|
||
if($email_required) { | ||
return $this->getData('account/email'); | ||
} else { | ||
$email = $this->getData('account/email'); | ||
if (empty($email)) { | ||
$host = $this->_scopeConfig->getValue( | ||
self::XML_PATH_DEFAULT_EMAIL_DOMAIN, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
$account = time(); | ||
$email = $account . '@' . $host; | ||
$account = $this->getData('account'); | ||
$account['email'] = $email; | ||
$this->setData('account', $account); | ||
} | ||
|
||
return $email; | ||
} | ||
|
||
} | ||
|
||
/** | ||
|
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.
Please, make constant private
Uh oh!
There was an error while loading. Please reload this page.
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.
Needs a PHPDOC too