Skip to content

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

Conversation

solwininfotech
Copy link
Contributor

Description (*)

Fixed Issues (if relevant)

  1. Admin Order - Email is Now Required - Magento 2.2.6 #22251: Admin Order - Email is Now Required - Magento 2.2.6

Manual testing scenarios (*)

  1. Sales -> Orders
  2. Create New Order
  3. Create New Customer
  4. Select Store View or if Single-Store Mode it brings you to the Order Information Page
  5. Email field is now required

Before Fix:
Customer Email is required in Admin Order Creation.
22251_before
After fixed Customer Email is not required in Admin Order Creation and once order is created customer email will be created automatically by system.
22251_after
22251_dynamic_email_creation

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@m2-assistant
Copy link

m2-assistant bot commented May 4, 2019

Hi @solwininfotech. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented May 4, 2019

CLA assistant check
All committers have signed the CLA.

@solwininfotech
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech, here is your new Magento instance.
Admin access: https://pr-22648.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@rogyar rogyar self-assigned this May 5, 2019
@rogyar
Copy link
Contributor

rogyar commented May 5, 2019

Approving this one.

Basically, this PR reverts the fix provided in b1eece2#diff-b79fbcef70631d52e90840aaf9a0d94d .

This fix results in confusion since the email auto-generation upon guest order creation from admin panel were considered as a useful feature. And the fix prevents store owners from using the expected behavior. Check the original issue for details.

@magento-engcom-team
Copy link
Contributor

Hi @rogyar, thank you for the review.
ENGCOM-5060 has been created to process this Pull Request

@sdzhepa
Copy link
Contributor

sdzhepa commented May 7, 2019

Hello

@solwininfotech, @trucatchtraps, @rogyar @driskell

Thank you for contribution and collaboration!

Unfortunately, these changes will not be approved by Magento internal team.

Changes from b1eece2 were made by the Core team intentionally.
It was based on several reports and escalations/complaints from different clients through Magento Support channel.
The main idea was that specific of their businesses did not allow to accept any auto-generated email addresses in the case when field is empty(previous behavior).

But after reading all argumentation from issue description #22251
I see that could be different cases based on business needs

So, after several internal discussion, I propose the next solution that should cover both cases:

NOTE:

Due to several requests, I want to mention that proposed solution and each requirement were
discussed and approved with Magento Product Manager @chernenm

"It should be a configurable option in Configuration" with next requirements:

  1. The option should be as drop-down element with values Yes/No
  2. The option should be System > Configuration > CUSTOMERS > Customer Configuration section Create New Account Options. Between "Show VAT Number on Storefront" and "Default Email Domain"
  3. Element Title: "Email is required field for Admin order creation"
  4. Hint message under field: "If set YES Email field will be required during Admin order creation for new Customer."
  5. Element scope: store view
  6. Default value = No
  7. The option should affect only Order creation flow for a new customer from Admin side and should not be any impact on other functionality(like Customer creation flow or so)

When option set to "No" Magento should work as it was before b1eece2
When option set to "Yes" Magento should work as now, after

email

@solwininfotech
Copy link
Contributor Author

@sdzhepa Got your point, we will add the settings in the configuration, thank you for your feedback.

@solwininfotech
Copy link
Contributor Author

@sdzhepa, I have updated the code.
Please view the screens for.

  1. Email required setting in the configuration.
    email_required_config_setting

  2. Create order when Email required setting is No
    create_order_when_setting_is_no

  3. Auto-generated email once "Create order when Email required setting is No".
    auto_generate_email

  4. Email required setting is Yes in the configuration.
    email_required_config_setting_yes

  5. Email required validation for customer email address once "Create order when Email required setting is Yes".
    create_order_when_setting_is_yes

  6. Admin entered customer email once "Create order when Email required setting is Yes".
    admin_entered_email

@solwininfotech
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech, here is your new Magento instance.
Admin access: https://pr-22648.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@solwininfotech
Copy link
Contributor Author

@magento-engcom-team
Testing is done all works fine.

@sdzhepa
Copy link
Contributor

sdzhepa commented May 8, 2019

@solwininfotech
Thank you for so quick reaction and code changes!

@solwininfotech
Copy link
Contributor Author

Hi @sdzhepa @rogyar

Semantic Version Checker build is filed with minor level because of the following reason.
M071 Constant has been added.
V015 [public] Method has been added.

Can you help me what I need to fix and how or it is okay because of new things are added?
minor_errors

@solwininfotech
Copy link
Contributor Author

@sidolov , Thank you for reviewing this thread let me know I need to update in this.

@ghost
Copy link

ghost commented Jun 19, 2019

@magento-cicd2 unfortunately, only members of the maintainers team are allowed to unassign developers from the pull request

@trucatchtraps
Copy link

I finally was able to remove the required * for the email address with a custom module. But now when I try to place an order without an email address, I receive the following errors.

The value of attribute "Email" must be set
Validation is failed.

@solwininfotech
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @solwininfotech, here is your new Magento instance.
Admin access: https://pr-22648.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@solwininfotech
Copy link
Contributor Author

Hi @trucatchtraps

Changes in this branch will be more helpful to you because of this code does not has an error [The value of attribute "Email" must be set Validation is failed.] as well as it has an admin setting that allows you to add an order with or without a customer email address .

Click here for more details.

Thank you.

@rogyar rogyar removed their assignment Aug 7, 2019
@@ -39,6 +39,8 @@ class Account extends AbstractForm
*/
protected $_extensibleDataObjectConverter;

const XML_PATH_EMAIL_REQUIRED_CREATE_ORDER = 'customer/create_account/email_required_create_order';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make constant private

Copy link
Contributor

@driskell driskell Aug 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a PHPDOC too

*
* @return bool
*/
public function isEmailRequiredCreateOrder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make method private

@@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make constant private

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having said that - I notice the PHPDOC is missing for this constant.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -2029,7 +2030,30 @@ protected function _validate()
*/
protected function _getNewCustomerEmail()
{
return $this->getData('account/email');
$email_required = $this->_scopeConfig->getValue(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, avoid underscore in the variable naming

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@ghost ghost assigned sidolov Aug 7, 2019
@@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -2029,7 +2030,30 @@ protected function _validate()
*/
protected function _getNewCustomerEmail()
{
return $this->getData('account/email');
$email_required = $this->_scopeConfig->getValue(
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@solwininfotech
Copy link
Contributor Author

Thank you for updated, I am working on this.

@sidolov
Copy link
Contributor

sidolov commented Sep 4, 2019

@solwininfotech , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Sep 4, 2019
@m2-assistant
Copy link

m2-assistant bot commented Sep 4, 2019

Hi @solwininfotech, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@trucatchtraps
Copy link

So will these changes be implemented in a new version?

@solwininfotech
Copy link
Contributor Author

Hi @sidolov
How are you?
Not sure after remote upstream Magento 2 git repo, my this branch was stopped working, I tried all the possible cases but it was not worked so I have done all the changes in a new branch and created a pull request for that. Is that possible you can review it. Here is the branch pull request #24479.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants