Remove registration form field in OpenCart

Remove registration form field in OpenCart

You have your online store all setup but the client calls you and says that they really don’t need the Fax field in the registration form because they don’t really use one. So they want you to remove registration form field in OpenCart and get rid of those fields that actually make visitors annoyed. There are fields that can be easily removed but there are also mandatory fields that require more detailed attention. This post describes how to remove registration form field in OpenCart that is not mandatory such as the Fax form field.


Mandatory form fields in OpenCart are based on PHP error handling. If you delete the field from the template file, the PHP code is still going to look for that field and if it doesn’t find a value for it, it will throw an error.
Since the Fax form field is non-required field (same as fields Company and Address 2) you may just delete them from the template file and you’re done. PHP won’t bother you with any errors. So here is what needs to be done.

Remove registration form field in OpenCart

1. Locate the theme template file – register.tpl

If you are using a default OpenCart theme then your template file is located in:
catalog/view/theme/default/template/account/register.tpl
If you are using some other theme then the path is slightly different:
catalog/view/theme/NameOfYourTheme/template/account/register.tpl

2. Locate the Fax form field code

The  code for this field should be around line 47 (Version 1.5.x):


</tr>
    <td><?php echo $entry_fax; ?></td>
    fax" value="php echo $fax; ?>" /></td>
</tr>

For Version 2.x the code for Fax field is around line 81:


<div class="form-group">
    <label class="col-sm-2 control-label" for="input-fax"><?php echo $entry_fax; ?></label>
    <div class="col-sm-10">
    fax" value="php echo $fax; ?>" placeholder="php echo $entry_fax; ?>" id="input-fax" class="form-control" />
    </div>
</div>

I recommend to comment the code rather than to delete it, because there will be some cases after you remove registration form field in OpenCart that your client might change their mind and want you to put the field back in its original place.

3. Copy the register.tpl file back to the server

And you’re done! Once you copy the file back to its location and reload the registration page, you should NOT see the Fax form field. That’s how you remove a non-mandatory registration form field in OpenCart.

APPENDIX

Please note that post code field is by default non-mandatory, but if you wish you can make it mandatory in the Dashboard settings by following these steps:

1. Navigate to: System⇒Localisation⇒Countries
2. Select the country to which your store is registered and click Edit
3. Find the radio button Postcode Required and check Yes, and then click the Save button.

This will work for a Register Account and for Guest Checkout options.

6 comments

Leave a Reply

  1. dezareo · December 24, 2015

    Great article

  2. Simon Baskar Rao · December 24, 2015

    How can i remove the address too !

    • janoshke · December 24, 2015

      Hi Simon,

      The scope of this tutorial is removal of NON-mandatory form fields. Please stay tuned for another post about removal of mandatory fields.
      Mandatory fields, aside from the template file, have to be removed from controller files (located in controller/account/register.php) and delete its validation from validate() function.
      Roughly said you delete it from the view and also remove the same from the controller file to avoid errors. But the post about this is yet to come…

  3. Dev44 · December 24, 2015
    • janoshke · December 24, 2015

      Thanks for the comment. Good modules are also welcomed. Cheers.