@@ -2038,31 +2038,51 @@ protected function _validate()
2038
2038
*/
2039
2039
protected function _getNewCustomerEmail ()
2040
2040
{
2041
- $ emailrequired = $ this ->_scopeConfig ->getValue (
2042
- self ::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER ,
2043
- \Magento \Store \Model \ScopeInterface::SCOPE_STORE
2044
- );
2041
+ $ emailrequired = $ this ->getIsEmailRequired ();
2045
2042
2046
2043
if ($ emailrequired ) {
2047
2044
return $ this ->getData ('account/email ' );
2048
2045
} else {
2049
2046
$ email = $ this ->getData ('account/email ' );
2050
2047
if (empty ($ email )) {
2051
- $ host = $ this ->_scopeConfig ->getValue (
2052
- self ::XML_PATH_DEFAULT_EMAIL_DOMAIN ,
2053
- \Magento \Store \Model \ScopeInterface::SCOPE_STORE
2054
- );
2055
- $ account = time ();
2056
- $ email = $ account . '@ ' . $ host ;
2057
- $ account = $ this ->getData ('account ' );
2058
- $ account ['email ' ] = $ email ;
2059
- $ this ->setData ('account ' , $ account );
2048
+ $ email = $ this -> generateEmail ();
2060
2049
}
2061
-
2062
2050
return $ email ;
2063
2051
}
2064
2052
}
2065
2053
2054
+ /**
2055
+ * Check email is require
2056
+ *
2057
+ * @return bool
2058
+ */
2059
+ protected function getIsEmailRequired ()
2060
+ {
2061
+ return $ this ->_scopeConfig ->getValue (
2062
+ self ::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER ,
2063
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
2064
+ );
2065
+ }
2066
+
2067
+ /**
2068
+ * Generate Email
2069
+ *
2070
+ * @return string
2071
+ */
2072
+ protected function generateEmail ()
2073
+ {
2074
+ $ host = $ this ->_scopeConfig ->getValue (
2075
+ self ::XML_PATH_DEFAULT_EMAIL_DOMAIN ,
2076
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
2077
+ );
2078
+ $ account = time ();
2079
+ $ email = $ account . '@ ' . $ host ;
2080
+ $ account = $ this ->getData ('account ' );
2081
+ $ account ['email ' ] = $ email ;
2082
+ $ this ->setData ('account ' , $ account );
2083
+ return $ email ;
2084
+ }
2085
+
2066
2086
/**
2067
2087
* Checks id shipping and billing addresses are equal.
2068
2088
*
0 commit comments