opencartopencart2.xopencart2.3

How to reduce the number of fields requested during registration? | OpenCart 2


Is it possible to adjust / remove entry fields on registration page?

Image:

enter image description here


Solution

  • In admin panel go to Customer > Custom Field

    Here you can add any custom field you want. Just check Required before saving new field, and enable it. After that you will see it in your registration page.

    Removing unnecessary field, like Fax

    Open catalog/view/theme/default/template/account/register.tpl

    Find following

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

    Replace it with following (using same name="fax" as above)

    <input type="hidden" name="fax" value="" />
    

    Removing necessary field, like Address

    Do everything from the previous chapter

    Open catalog/view/theme/default/template/account/register.tpl

    Find following

    <div class="form-group required">
      <label class="col-sm-2 control-label" for="input-address-1"><?php echo $entry_address_1; ?></label>
      <div class="col-sm-10">
        <input type="text" name="address_1" value="<?php echo $address_1; ?>" placeholder="<?php echo $entry_address_1; ?>" id="input-address-1" class="form-control" />
        <?php if ($error_address_1) { ?>
        <div class="text-danger"><?php echo $error_address_1; ?></div>
        <?php } ?>
      </div>
    </div>
    

    Replace it with following (using same name="fax" as above)

    <input type="hidden" name="address_1" value="" />
    

    Now open catalog/controller/account/register.php

    Find private function validate() {, Inside of this function we can see all validations.

    Look for

    if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
      $this->error['address_1'] = $this->language->get('error_address_1');
    }
    

    and remove (or comment) it.