In some cases store owners might need to have some optional extra information regarding their clients, for example a date of birth might be needed in record for certain purchases or other verification reasons. In today’s article we’re going to add such a field to the Account Details tab under the My Account page and then we will display the information entered in the user profile page for easy access.
Install and activate a child theme
The first step on our process here is to create and install a child theme. If you are using one of our themes you can easily grab its child theme from our downloads section. If not, you can read our beginner’s guide on child themes to create your own. This step is essential in order to preserve our changes throughout theme updates.
Create the custom field
Adding the custom field is pretty easy. We’ll use the woocommerce_edit_account_form hook to add the field and the woocommerce_save_account_details one to save the entered information.
Our new field will appear below the password management fields.
Display the field
Once the customer has entered their date of birth we can display them in the user profile page so we have easy access to the information when needed.
To show the field use the show_user_profile and edit_user_profile hooks with a priority of 15 in order for our info to be displayed below the WooCommerce billing and shipping information.
Wrapping up
With a couple of simple code snippets we have added a custom account field and displayed its information on the user profile page. Now we can utilize the new information to improve the shopping experience for our customers and make our life easier as shop owners. Did you find this guide helpful, or do you have any ideas for future guides? Let us know in the comments below.
2 comments
Thank you for the easy tutorial! This date of birth function was exactly what I was trying to add.
Is there a way to add the field also to the Woocommerce checkout page? So that it has to be filled out when someone takes an order.
Thank you!
Hello.
You can check out WooCommerce’s documentation here on how to customize checkout fields in order to add your new field to the checkout page.