How to Add a Registration Form to WooCommerce Stores

This time we are going to feature the simplest possible ways to can follow to add a registration form to WooCommerce stores and shopping platforms.

A user friendly registration form on is one of the essential parts any kind of website should have. Whether you own a hotel or travel agency, service provision or commercial website.

You need to provide your potential and prospective customers with registration forms to input their personal data and other details into the registration fields and submit to you for services, products, subscriptions, plans or more.

What is a registration form?

A registration form is a sequence of fields which need to be filled out with user information.

On the whole, it is an ideal way to collect the needed information from your web users, clients, customers and followers who are somehow interested in your business, store, company, non profit organization or whatever it is.

What you should take into account when you want to add a registration form to WooCommerce stores
Well, registering for dozens of websites and blogs is not the most pleasant process for Internet users.

But the truth is that they are already used to it and are ready to provide you with their basic information in most of the cases.

However, you need to take care of delivering a real value around your registration form by explaining why a web visitor should register to your site.

Add a Registration Form to WooCommerce Stores

Avoid demanding too much information, leave only logical fields, explain why you, make privacy and security policy precise and easy to understand.

Why it is important to optimize your commercial website’s registration form
That the availability and simplicity of a registration form directly determine the number of users in your database and affects the user’s desire to continue his relationship with your website.

Thus, well formatted and well operating contact form may bring more clients and more business opportunities.

Moreover, if you manage to add a registration form to WooCommerce store that is simple, easy to understand and flawlessly functioning, it will save you from a flurry of letters needing technical support which will inevitably become a headache for you and your staff.

Now when we have demonstrated the importance of integrating a registration form into your online WooCommerce environment, let’s understand how it can be done from a technical standpoint.

How to add a registration form to WooCommerce stores
First, you need to enable the form from WooCommerce backend settings. Follow the path WooCommerce, Settings, Accounts, Enable Registration. You will be taken to the window from where you need to check the box beside “Enable customer registration on the “My account” page”.

Here you can control also other settings like displaying returning customer login reminder on the checkout page, automatically generate username or customer password, etc. to make the registration process more user optimized.

Once you are done with this settings part, the registration form is going to be displayed on the frontend, which means that your efforts to add a registration form to WooCommerce were not in vain.

As you can see now, the form you have added is quite simple and modest. Therefore, the next step is to add fields in the registration form you have already enabled.

You can insert the following code at the end of your functions.php file if you want to add some basic fields like first and last name, phone number, email and password.

function wooc_extra_register_fields() {?>

<p class=”form-row form-row-wide”>

<label for=”reg_billing_phone”><?php _e( ‘Phone’, ‘woocommerce’ ); ?></label>

<input type=”text” class=”input-text” name=”billing_phone” id=”reg_billing_phone” value=”<?php esc_attr_e( $_POST[‘billing_phone’] ); ?>” />

</p>

<p class=”form-row form-row-first”>

<label for=”reg_billing_first_name”><?php _e( ‘First name’, ‘woocommerce’ ); ?><span class=”required”>*</span></label>

<input type=”text” class=”input-text” name=”billing_first_name” id=”reg_billing_first_name” value=”<?php if ( ! empty( $_POST[‘billing_first_name’] ) ) esc_attr_e( $_POST[‘billing_first_name’] ); ?>” />

</p>

<p class=”form-row form-row-last”>

<label for=”reg_billing_last_name”><?php _e( ‘Last name’, ‘woocommerce’ ); ?><span class=”required”>*</span></label>

<input type=”text” class=”input-text” name=”billing_last_name” id=”reg_billing_last_name” value=”<?php if ( ! empty( $_POST[‘billing_last_name’] ) ) esc_attr_e( $_POST[‘billing_last_name’] ); ?>” />

</p>

<div class=”clear”></div>

<?php

}

add_action( ‘woocommerce_register_form_start’, ‘wooc_extra_register_fields’ );

Once the page is refreshed, you will find new fields added to your registration form.

Whenever you want to connect your registration form with billing address, you need to add the prefix  “billing” before the field name. Below you can find the most commonly used form fields:

billing_first_name, billing_last_name, billing_company, billing_address_1, billing_address_2,

billing_city, billing_postcode, billing_country, billing_state, billing_email, billing_phone

Now it’s time to validate the data in the form fields with another piece of code to be added to functions.php file. Use the below mentioned lines of code for data validation:

/**

* register fields Validating.

*/

function wooc_validate_extra_register_fields( $username, $email, $validation_errors ) {

if ( isset( $_POST[‘billing_first_name’] ) && empty( $_POST[‘billing_first_name’] ) ) {

$validation_errors->add( ‘billing_first_name_error’, __( ‘<strong>Error</strong>: First name is required!’, ‘woocommerce’ ) );

}

if ( isset( $_POST[‘billing_last_name’] ) && empty( $_POST[‘billing_last_name’] ) ) {

$validation_errors->add( ‘billing_last_name_error’, __( ‘<strong>Error</strong>: Last name is required!.’, ‘woocommerce’ ) );

}

return $validation_errors;

}

add_action( ‘woocommerce_register_post’, ‘wooc_validate_extra_register_fields’, 10, 3 );

This code is checking $_POST array for the form values and including an error message whenever the value is not present or data is invalid.

Finally, you need to save these values in the database. As soon as the values are validated, you need to use the following code in your functions.php to insert values in the database:

/**

* Below code save extra fields.

*/

function wooc_save_extra_register_fields( $customer_id ) {

if ( isset( $_POST[‘billing_phone’] ) ) {

// Phone input filed which is used in WooCommerce

update_user_meta( $customer_id, ‘billing_phone’, sanitize_text_field( $_POST[‘billing_phone’] ) );

}

if ( isset( $_POST[‘billing_first_name’] ) ) {

//First name field which is by default

update_user_meta( $customer_id, ‘first_name’, sanitize_text_field( $_POST[‘billing_first_name’] ) );

// First name field which is used in WooCommerce

update_user_meta( $customer_id, ‘billing_first_name’, sanitize_text_field( $_POST[‘billing_first_name’] ) );

}

if ( isset( $_POST[‘billing_last_name’] ) ) {

// Last name field which is by default

update_user_meta( $customer_id, ‘last_name’, sanitize_text_field( $_POST[‘billing_last_name’] ) );

// Last name field which is used in WooCommerce

update_user_meta( $customer_id, ‘billing_last_name’, sanitize_text_field( $_POST[‘billing_last_name’] ) );

}

}

add_action( ‘woocommerce_created_customer’, ‘wooc_save_extra_register_fields’ );

Finished! Now you have successfully collected, validated and added values to your database and they are ready for the use.

Related Post: The Comparison Between BigCommerce vs WooCommerce – Which One is Better?

As you can see, you can quickly add a registration form to WooCommerce store, add fields to it and be sure your users are satisfied with your work.

As a business owner, it is important that you setup a website at the earliest and while doing so, make sure that you set it up on a WordPress platform as it offers you greater flexibility than most.

Make sure that you choose a theme that is woocommerce compatible and that you set up a registration form to woocommerce stores.

The process is fairly easy and should not take you more than a few minutes at most. In case, you were wondering why bother going through all the hassle of setting up a registration form to woocommerce stores, then you may want to check out the reasons listed below.

  • User information: By using registration forms on your website, you can get users to subscribe to daily updates as well as make sure that they receive the latest information regarding your products and services. You can use the information that they shared with you to optimize your marketing so that you can reach out to your key demographic more effectively than before.
  • User engagement: By using registration forms, you would essentially be interacting with your users. With increased user engagement, the chances of a conversion and an actual sale goes up which Is why you should make sure that your woo commerce comes with registration form enabled in the background.
  • Marketing: Any information that the user provides should prove to be invaluable. You can use this information to directly market your products and services to them directly but make sure that you are not spamming as that is strictly disallowed.

    More importantly, you can streamline your marketing strategy, use the information provided by the customers and target them with specific ads, on the same.

  • Easy setup: The process to set up your registration form is fairly easy; all you need to do is on head over to the woocommerce admin area and from the backend, enable the registration form and activate the same. You can even customize it so that it appeals to new customers and consequently, they would be interested in providing you with the info you need via the registration form that you had just installed on your website.
  • SEO: With the registration form on your website, you should be able to provide your users with an enhanced user experience and this in turn should help boost those SERP rankings. This should lead to more traffic and therefore should help increase page views, impressions and much more.

These are some of the reasons as to why you should install a registration form on your website at the earliest.

More importantly, you need to make sure that you do not spam your users as that is one sure fire way to chase away new customers and prospective leads.

You need to offer them a trade off, one where you would provide them with some freebie, offer or more information for registering on your site.

By doing so, you are offering them something valuable in return and this should definitely peak their interest and cause them to enter their information on the registration form.

About Sonl Sinha

Sonl SinhaSonl Sinha is a passionate writer as well as WordPress and WooCommerce rockstar who loves to share insights on various topics through his engaging blog posts. He runs a successful website design and digital marketing company. With 15+ years of experience in WordPress theme development, he strives to inform and inspire readers with his thought-provoking content. He helps thousands of small and medium businesses and startups create a unique online presence. Follow Sonl Sinha for your regular dose of knowledge and inspiration.

Do check out our free WP themes and WordPress themes bundle