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.

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):



    
    fax" value="php echo $fax; ?>" />

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

fax” value=”php echo $fax; ?>” placeholder=”php echo $entry_fax; ?>” id=”input-fax” class=”form-control” />

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.

APPENDIX 2

For OpenCart version 3.x you should look for strings input-payment-address-2 and input-payment-company in the following files: guest.twig, guest_shipping.twig, payment_address.twig, register.twig, shipping_address.twig

All of them are located in: /catalog/view/theme/YOUR-THEME-NAME/template/checkout

Comment those strings and you are all set! 😉

By janoshke

Web developer and IT consultant. Freelancer with full respect for OpenCart and WordPress. Gamer, (ex)drummer and parent.

6 comments

    1. 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…

Leave a ReplyCancel reply

Exit mobile version
%%footer%%