Skip to content

Improvements to Customer generator #137

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

Merged
merged 4 commits into from
Jul 9, 2024
Merged

Conversation

coreymckrill
Copy link
Contributor

@coreymckrill coreymckrill commented Jun 18, 2024

Changes proposed in this Pull Request:

Makes the data generated by the Customers generator more "coherent" and contextual to a locale, plus a few other enhancements to make it more useful for testing.

  • Adds an optional country parameter to the generator, which is used to localize the Faker library that produces the random data. If a country isn't specified, falls back on randomly selecting any country that the store is configured to sell to.
  • Ensures that first, last, and/or company name that is generated is then used when generating username and email address.
  • Adds an optional type parameter to the generator, to specify if the customer should be a person or a company. Company customers do not have the first and last name fields filled in.
  • Sets the password of every created customer account to password so that it's easy to log in as that customer and see the store from that perspective.
  • Misc tweaks.

Fixes #131
Fixes #108
Fixes #66

How to test the changes in this Pull Request:

  1. Open a tab to your test site's admin and go to WooCommerce > Customers. Sort the table by Date Registered so you can quickly see new customers when they are generated.
  2. In your terminal, view the docs for the customers cli command: wp help wc generate customers. Note the optional parameters for the command.
  3. In your browser, go to WooCommerce > Settings. Make sure "Selling location(s)" is set to "Sell to all countries".
  4. Try the default command: wp wc generate customers. You should get 10 new customers, from a wide variety of countries.
  5. Now change the "Selling location(s)" setting to one or two specific countries, and run the command again. All 10 of the generated customers should be from those countries.
  6. Try specifying some different countries on the command line, e.g. wp wc generate customers 1 --country=DE and see if the generated data matches. Try some countries that don't use a Latin alphabet, e.g. CN or RU.
  7. Try specifying a country code that is invalid.
  8. Try choosing just one type of customer, e.g. wp wc generate customers --type=company --country=FR

Changelog entry

Improved test data for the Customers generator.

@coreymckrill coreymckrill self-assigned this Jun 18, 2024
@coreymckrill coreymckrill requested review from a team and naman03malhotra and removed request for a team June 21, 2024 22:26
@coreymckrill coreymckrill marked this pull request as ready for review June 21, 2024 22:26
Copy link

@naman03malhotra naman03malhotra left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, it works well 🎉

Two things:

  • While testing I observed that cities for some countries are set randomly, as in the city being set is part of some other country, probably that's fine.
  • We should do version bump and add changelog as part of this PR.

image

@coreymckrill
Copy link
Contributor Author

Thanks @naman03malhotra

While testing I observed that cities for some countries are set randomly, as in the city being set is part of some other country, probably that's fine.

I think this happens when the Faker package doesn't have any city data for that particular locale, so it falls back on the "default" locale, which is en_US.

We should do version bump and add changelog as part of this PR.

Planning to do that, but as a separate PR, because there are several other changes for a new version besides this one!

@coreymckrill coreymckrill merged commit 49a0c9d into trunk Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants