Skip to content

Commit

Permalink
Update Create.php
Browse files Browse the repository at this point in the history
  • Loading branch information
swnsma authored Sep 16, 2019
1 parent 7e5bb80 commit b5265e8
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -2038,27 +2038,23 @@ protected function _validate()
*/
protected function _getNewCustomerEmail()
{
$emailrequired = $this->getIsEmailRequired();

if ($emailrequired) {
return $this->getData('account/email');
} else {
$email = $this->getData('account/email');
if (empty($email)) {
$email = $this-> generateEmail();
}
return $email;
$email = $this->getData('account/email');

if ($email || $this->getIsEmailRequired()) {
return $email;
}

return $this->generateEmail();
}

/**
* Check email is require
*
* @return bool
*/
protected function getIsEmailRequired()
private function getIsEmailRequired(): bool
{
return $this->_scopeConfig->getValue(
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
Expand All @@ -2069,7 +2065,7 @@ protected function getIsEmailRequired()
*
* @return string
*/
protected function generateEmail()
private function generateEmail(): string
{
$host = $this->_scopeConfig->getValue(
self::XML_PATH_DEFAULT_EMAIL_DOMAIN,
Expand All @@ -2080,6 +2076,7 @@ protected function generateEmail()
$account = $this->getData('account');
$account['email'] = $email;
$this->setData('account', $account);

return $email;
}

Expand Down

0 comments on commit b5265e8

Please sign in to comment.