PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 8, 2022

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

 November 08, 2022     opencart, opencart2.3, opencart2.x     No comments   

Issue

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.



Answered By - focus.style
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing