如何减少注册时请求的字段数量? |打开购物车 2

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

是否可以调整/删除注册页面上的输入字段?

图片:

在管理面板中转到客户 > 自定义字段

在这里您可以添加任何您想要的自定义字段。只需在保存新字段之前检查 Required 并启用它。之后您将在您的注册页面中看到它。

删除不必要的字段,例如 传真

打开catalog/view/theme/default/template/account/register.tpl

找到以下内容

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

将其替换为以下内容(使用与上述相同的 name="fax"

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

删除必要的字段,例如地址

做上一章的所有事情

打开catalog/view/theme/default/template/account/register.tpl

找到以下内容

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

将其替换为以下内容(使用与上述相同的 name="fax"

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

现在打开catalog/controller/account/register.php

找到private function validate() {,在这个函数里面我们可以看到所有的验证。

寻找

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');
}

并删除(或评论)它。