Skip to content
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

Fixed #18823: Prefix dropdown in checkout doesn't select empty value by defau… #26640

Closed
wants to merge 6 commits into from

Conversation

mikebox
Copy link

@mikebox mikebox commented Feb 2, 2020

Fixed #18823: Prefix dropdown in checkout doesn't select empty value by default if required

Description (*)

Added a condition to ensure the options provided by the customers start with the separator(;). If the separator exists at the start of the options, adding an empty option in the select.

Additional Notes:
array_filter() removes the empty characters. Removing that might create additional problems of having empty options in the middle. So added a condition to ensure the starting character and act based on that.

Fixed Issues (if relevant)

  1. Prefix dropdown in checkout doesn't select empty value by default if required #18823: Prefix dropdown in checkout doesn't select empty value by default if required

Manual testing scenarios (*)

  1. In Admin Backend go to Stores > Configuration > Customers > Name and Address Options
  2. Set "Show Prefix" to "Required"
  3. Set "Prefix Dropdown Options" to ";Mr.;Mrs."
  4. Save Config
  5. Go to your store
  6. Add a item to your cart
  7. Go to checkout

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 are green)

@m2-assistant
Copy link

m2-assistant bot commented Feb 2, 2020

Hi @mikebox. 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@lenaorobei lenaorobei self-assigned this Feb 5, 2020
@lenaorobei
Copy link
Contributor

Related to #20896

@lenaorobei
Copy link
Contributor

As per discussion with PO @mbrinton01, the expected behavior is:
Mr;Ms; - select with Mr , Ms and ""
;Mr;Ms - select with "", Mr and Ms
;Mr;Ms;- select with "", Mr, Ms and ""

#17861 was configuration issue but not the functional.

@@ -98,6 +98,11 @@ private function prepareNamePrefixSuffixOptions($options, $isOptional = false)
return false;
}
$result = [];

if (substr($options, 0, 1) === ";") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this check.

if (substr($options, 0, 1) === ";") {
$result = array_merge([' ' => ' '], $result);
}

$options = array_filter(explode(';', $options));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$options = array_filter(explode(';', $options));
$options = explode(';', $options);

Copy link
Contributor

@lenaorobei lenaorobei left a comment

Choose a reason for hiding this comment

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

@mikebox please see my comments and consider covering these cases with MFTF tests. Thank you.

@swnsma
Copy link
Contributor

swnsma commented Feb 12, 2020

Hi @mikebox @lenaorobei
Could we use a little bit complex but more obvious approach called 'Dynamic Rows'?
https://devdocs.magento.com/guides/v2.3/ext-best-practices/tutorials/dynamic-row-system-config.html

@lenaorobei
Copy link
Contributor

I like this idea! Let me confirm with @mbrinton01 since it will be a pretty big UI change and I believe we should take care of suffix as well.

@mbrinton01
Copy link

I'm fine with this approach as it should return the same experience for the user.

@engcom-Echo
Copy link
Contributor

I will take care of test coverage.

@engcom-Echo engcom-Echo self-assigned this Feb 21, 2020
@lenaorobei lenaorobei added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Feb 25, 2020
lenaorobei
lenaorobei previously approved these changes Feb 26, 2020
@magento-engcom-team
Copy link
Contributor

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

Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

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

.

Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

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

Hi @mikebox.

During testing, we faced the issue.

Problem: Prefix dropdown in checkout doesn't select an empty value by default

Manual testing scenario:

  1. In Admin Backend go to Stores > Configuration > Customers > Name and Address Options;
  2. Set "Show Prefix" to "Required";
  3. Set "Prefix Dropdown Options" to ";Mr.;Mrs.";
  4. Save Config and go to your store;
  5. Add an item to your cart and go to checkout;

Actual Result: The value "Mr." is selected by default
after2

@mikebox Could you take a look?

Thanks!

@ghost ghost dismissed lenaorobei’s stale review February 28, 2020 09:37

Pull Request state was updated. Re-review required.

@lenaorobei
Copy link
Contributor

Closing this PR due to inactivity. Please feel free to reopen if you are going to continue working on it.
Thank you.

@lenaorobei lenaorobei closed this Mar 24, 2020
@m2-assistant
Copy link

m2-assistant bot commented Mar 24, 2020

Hi @mikebox, 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.

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.

Prefix dropdown in checkout doesn't select empty value by default if required
8 participants