This Plugin for WordPress allows the shop manager to create a new user while creating a new order.
With a single click on the checkbox, a new user gets created and linked to the newly created order.
WooCommerce allows you to get orders from clients via the frontend, but you can also create those easily in the backend of WordPress. This is especially useful when you get orders by phone or email.
But what happens, if you have recurring clients? You have to fill out the billing and delivery fields every time. Unless you create a new user, which stores those data and groups the order to the customer.
I had this situation with a client of mine. They got a decent amount of orders outside of the shop and often from the same customers.
One Solution for this problem is, to go to the user page and create a new user. Then create the order and select the user. Doable, but not convenient at all.
My idea was to create a solution as simple and convenient as possible. One Checkbox at the end of the billing fields, that’s all that should be visible for the shop manager. If checked, multiple things happen in the background.
First, a new user gets created. It uses the name and surname from the billing information. Then the order gets linked to the new user. In some cases, you don’t have the email address of the client. If so, a „fake“ email name gets created. Looking something like that: email@example.com.
Also, the new user does not get any confirmation, that an account was created. I did not want to notify the user about his new account to prevent confusion.
The creation of this plugin was pretty straightforward.
I’ve added the checkbox with the action „woocommerce_admin_order_data_after_billing_address“. The field will only appear if the order is not assigned to a customer. So it is also possible, to create this new user after the order is created.
Next i hooked into „woocommerce_process_shop_order_meta“ to create the new user.
The hardest part for me was to deactivate the email that would be sent to the user. It was all a matter of finding the right hooks for the job. As well as to debug test this function. Since I could not just echo out in the action, I had to print it in the PHP error log to see what’s happening.
End of November, version 1.0 got released. And with that, my first publicly available plugin.
Because of its simple nature, there was not a lot to do or update in the coming months. Newer WordPress versions were supported out of the box, and it was quite quiet about this plugin.
It took around half a year, till I got a message, that the plugin is not working anymore. Time to have again a look.
After a chat with the user, I had kind of an idea, what the issue could be. Therefore I’ve tried a few strange names with special characters and invalid email addresses. And there it was. No error, no message no new user. Time for version 1.1.
This version, released mid of July 2021, brings a few fixes regarding the issue mentioned above.
And to make my life easier as well, I implemented some error handling functions. If adding a new user fails, an entry in the error log, as well as in the Simple History Plugin gets created. Which makes debugging so much more convenient.
Before this fix was ready, I got two feature requests. Preselection of the checkbox by default and sending of an email with the account information was asked. Because these were not complex functions to implement, I decided to add those to the 1.1 version as well.
After the creation of the options page, the check got added to the code. Everything was working just fine. The user got the Standard „Your account got created“ email from Woocommerce and I was about to call it a day.
But one thing was bothering me. How should the customer log himself in? Since he has no password and to use the „Lost password“-function was not obvious.
This leads me to the solution of creating a custom email. The default Woocommerce header and footer were added to get a more official look. And also, if the webmaster modified the email template, it will be shown in this email as well. Now, if the option is set, the new customer gets an email with his login credentials.
Next was the debugging and testing with all kinds of data. Updating the readme file and added a new screenshot of the options menu. To make the code beautiful and add comments is important for me. I know, my feature me will thank me.
After a few hundred downloads, two 5-Star reviews, and a few feature requests, Version 1.2 got released on the 6th of October 2021.
This Update was mostly done because of the requests I received. Since there is the option to send notifications to the user, there was no possibility to switch that on the fly. Before the creation of the new order, you had to go to the options menu to turn on or off the notifications. Therefore I added a second checkbox, which will be displayed, once the „Add Customer“ Checkbox is selected. This makes it easy to enable or disable this function before creating the user.
Also, it was important for me to give the user proper feedback about what happened. After saving the order, the admin/editor will now get a notice, if the creation and sending of the email were successful or not.
As the third big new feature, the support for custom billing and shipping fields has been added. In WordPress it is easily possible, to modify the billing and shipping fields to your needs and add new ones. Those custom fields were ignored by the Plugins before 1.2. Now they get saved as well and if you load the data for a new order, it gets populated as well.
At the start of February 2022, there was the release of version 1.3. In this version, a bug got fixed which was resulting in customers getting created on existing orders, due to the preselect-checkbox option.
The next few updates were mainly driven by user’s feedback. I added support for custom email templates with preview and added a few new hooks, to customize the plugin or solve unique user problems.
It is always very interesting for me to see, how other people use the plugin and what kind of special cases they have.
The Plugin is available in the official WordPress plugin directory and on Github