-1

我正在使用主题为crista_blue的 opencart 1.5.1 ,根据他们的网站,该主题与 opencart 1.5.1 兼容。

这里提出了一个非常相似的问题:-已解决- Opencart 无法加载区域/状态下拉列表,但那里的答案是“在控制器catalog/controller/account/register.php中没有调用这样的操作zone- 因此服务器返回 404 响应并且没有加载任何区域。 "

我的enroll.php文件确实有一个zone动作。这让我认为问题具有不同的性质。

另外两个人建立了这个站点,不再维护它。起初他们似乎使用默认register.tpl/register.php来创建帐户,但后来决定更改“注册”链接将您带到enroll.php/的欢迎页面enroll.tpl

这是网站https://www.mybaysix.com/。如果您单击底部的注册链接,您将进入一个显示区域/下拉列表但为空的表单。如果您点击继续,页面将显示必填字段的错误消息,区域/下拉框现在已加载选项。

这是enroll.tpl文件:

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href'];    ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
<h1><?php echo $heading_title; ?></h1>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<p><?php echo $text_buyer_information; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data"  id="register">


<!-- Company info -->
<h2><?php echo $text_your_address; ?> </h2>
<div class="content">
  <table class="form">
    <tr>
      <td><span class="required">*</span> <?php echo $entry_company; ?></td>
      <td><input type="text" name="company" value="<?php echo $company; ?>" />
        <?php if ($error_company) { ?>
        <span class="error"><?php echo $error_company; ?></span>
        <?php } ?></td>
    </tr>

    <tr>
      <td><span class="required">*</span> <?php echo $entry_federal_tax; ?></td>
      <td><input type="text" name="federal_tax" value="<?php echo $federal_tax; ?>" />
        <?php if ($error_federal_tax) { ?>
        <span class="error"><?php echo $error_federal_tax; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_dba; ?></td>
      <td><input type="text" name="dba" value="<?php echo $dba; ?>" />
        <?php if ($error_dba) { ?>
        <span class="error"><?php echo $error_dba; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_state_resale; ?></td>
      <td><input type="text" name="state_resale" value="<?php echo $state_resale; ?>" />
        <?php if ($error_state_resale) { ?>
        <span class="error"><?php echo $error_state_resale; ?></span>
        <?php } ?></td>
    </tr>

    <tr>
      <td> <?php echo $entry_store_website; ?></td>
      <td><input type="text" name="store_website" value="<?php echo $store_website; ?>" /></td>
    </tr>


    <tr>
      <td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
      <td><input type="text" name="address_1" value="<?php echo $address_1; ?>" />
        <?php if ($error_address_1) { ?>
        <span class="error"><?php echo $error_address_1; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><?php echo $entry_address_2; ?></td>
      <td><input type="text" name="address_2" value="<?php echo $address_2; ?>" /></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_city; ?></td>
      <td><input type="text" name="city" value="<?php echo $city; ?>" />
        <?php if ($error_city) { ?>
        <span class="error"><?php echo $error_city; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
      <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" />
        <?php if ($error_postcode) { ?>
        <span class="error"><?php echo $error_postcode; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_country; ?></td>
      <td><select name="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=account/register/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
          <option value=""><?php echo $text_select; ?></option>
          <?php foreach ($countries as $country) { ?>
          <?php if ($country['country_id'] == $country_id) { ?>
          <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
          <?php } else { ?>
          <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
          <?php } ?>
          <?php } ?>
        </select>
        <?php if ($error_country) { ?>
        <span class="error"><?php echo $error_country; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
      <td><select name="zone_id">
        </select>
        <?php if ($error_zone) { ?>
        <span class="error"><?php echo $error_zone; ?></span>
        <?php } ?></td>
    </tr>
  </table>
</div>
<h2><?php echo $text_your_password; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><span class="required">*</span> <?php echo $entry_password; ?></td>
      <td><input type="password" name="password" value="<?php echo $password; ?>" />
        <?php if ($error_password) { ?>
        <span class="error"><?php echo $error_password; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_confirm; ?></td>
      <td><input type="password" name="confirm" value="<?php echo $confirm; ?>" />
        <?php if ($error_confirm) { ?>
        <span class="error"><?php echo $error_confirm; ?></span>
        <?php } ?></td>
    </tr>
  </table>
</div>



<h2><?php echo $text_buyer_information; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
      <td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
        <?php if ($error_firstname) { ?>
        <span class="error"><?php echo $error_firstname; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
      <td><input type="text" name="lastname" value="<?php echo $lastname; ?>" />
        <?php if ($error_lastname) { ?>
        <span class="error"><?php echo $error_lastname; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_email; ?></td>
      <td><input type="text" name="email" value="<?php echo $email; ?>" />
        <?php if ($error_email) { ?>
        <span class="error"><?php echo $error_email; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
      <td><input type="text" name="telephone" value="<?php echo $telephone; ?>" />
        <?php if ($error_telephone) { ?>
        <span class="error"><?php echo $error_telephone; ?></span>
        <?php } ?></td>
    </tr>
    <tr>
      <td><?php echo $entry_fax; ?></td>
      <td><input type="text" name="fax" value="<?php echo $fax; ?>" /></td>
    </tr>
  </table>
</div>

<h2><?php echo $text_owner_information; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><?php echo $entry_owner_fname; ?></td>
      <td><input type="text" name="owner_fname" value="<?php echo $owner_fname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_owner_lname; ?></td>
      <td><input type="text" name="owner_lname" value="<?php echo $owner_lname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_owner_phone; ?></td>
      <td><input type="text" name="owner_phone" value="<?php echo $owner_phone; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_owner_fax; ?></td>
      <td><input type="text" name="owner_fax" value="<?php echo $owner_fax; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_owner_email; ?></td>
      <td><input type="text" name="owner_email" value="<?php echo $owner_email; ?>" /></td>
    </tr>
  </table>
</div>

<h2><?php echo $text_manager_information; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><?php echo $entry_manager_fname; ?></td>
      <td><input type="text" name="manager_fname" value="<?php echo $manager_fname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_manager_lname; ?></td>
      <td><input type="text" name="manager_lname" value="<?php echo $manager_lname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_manager_phone; ?></td>
      <td><input type="text" name="manager_phone" value="<?php echo $manager_phone; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_manager_fax; ?></td>
      <td><input type="text" name="manager_fax" value="<?php echo $manager_fax; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_manager_email; ?></td>
      <td><input type="text" name="manager_email" value="<?php echo $manager_email; ?>" /></td>
    </tr>
  </table>
</div>

<h2><?php echo $text_other_information; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><?php echo $entry_other_fname; ?></td>
      <td><input type="text" name="other_fname" value="<?php echo $other_fname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_other_lname; ?></td>
      <td><input type="text" name="other_lname" value="<?php echo $other_lname; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_other_phone; ?></td>
      <td><input type="text" name="other_phone" value="<?php echo $other_phone; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_other_fax; ?></td>
      <td><input type="text" name="other_fax" value="<?php echo $other_fax; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_other_email; ?></td>
      <td><input type="text" name="other_email" value="<?php echo $other_email; ?>" /></td>
    </tr>
  </table>
</div>


<h2><?php echo $text_newsletter; ?></h2>
<div class="content">
  <table class="form">
    <tr>
      <td><?php echo $entry_newsletter; ?></td>
      <td><?php if ($newsletter == 1) { ?>
        <input type="radio" name="newsletter" value="1" checked="checked" />
        <?php echo $text_yes; ?>
        <input type="radio" name="newsletter" value="0" />
        <?php echo $text_no; ?>
        <?php } else { ?>
        <input type="radio" name="newsletter" value="1" />
        <?php echo $text_yes; ?>
        <input type="radio" name="newsletter" value="0" checked="checked" />
        <?php echo $text_no; ?>
        <?php } ?></td>
    </tr>
  </table>
</div>
<?php if ($text_agree) { ?>
<div class="buttons">
  <div class="right"><?php echo $text_agree; ?>
    <?php if ($agree) { ?>
    <input type="checkbox" name="agree" value="1" checked="checked" />
    <?php } else { ?>
    <input type="checkbox" name="agree" value="1" />
    <?php } ?>
    <a onclick="$('#register').submit();" class="button"><span><?php echo $button_continue; ?></span></a></div>
</div>
<?php } else { ?>
<div class="buttons">
  <div class="right"><a onclick="$('#register').submit();" class="button"><span><?php echo $button_continue; ?></span></a></div>
</div>
<?php } ?>
</form>
<?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('select[name=\'zone_id\']').load('index.php?route=account/register/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script> 
<script type="text/javascript"><!--
$('.fancybox').fancybox({
width: 560,
height: 560,
autoDimensions: false
});
//--></script>  
<?php echo $footer; ?>

这是zone底部的功能enroll.php

public function zone() {
    $output = '<option value="">' . $this->language->get('text_select') . '</option>';

    $this->load->model('localisation/zone');

    $results = $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']);

    foreach ($results as $result) {
        $output .= '<option value="' . $result['zone_id'] . '"';

        if (isset($this->request->get['zone_id']) && ($this->request->get['zone_id'] == $result['zone_id'])) {
            $output .= ' selected="selected"';
        }

        $output .= '>' . $result['name'] . '</option>';
    } 

    if (!$results) {
        $output .= '<option value="0">' . $this->language->get('text_none') . '</option>';
    }

    $this->response->setOutput($output);
}  

我以前从未使用过opencart,所以如果有更多信息可以帮助找出问题,请询问。

编辑:我在下面尝试了 shadyyx 的第一个答案,这就是结果。

我改变.load('index.php?route=account/enroll/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');

我也尝试使用完整路径/catalog/controller/account/enroll/。下拉列表仍然没有填充。当我在没有填写任何内容的情况下点击继续时,顶部会出现错误Notice: Undefined index: zone_id in /home/mybaysix/public_html/catalog/controller/account/enroll.php on line 551

第 551 行enroll.phpif ($this->request->post['zone_id'] == '') { $this->error['zone'] = $this->language->get('error_zone'); }

4

1 回答 1

2

首先,欢迎来到 Stack OverFlow!

enroll.php可能确实具有该zone()功能,但在您的 HTML 的 JavaScript 中,您正在调用:

<script type="text/javascript"><!--
    $('select[name=\'zone_id\']').load('index.php?route=account/register/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script>

因此,您正在尝试加载/catalog/controller/account/register.php::zone()...

相反,您应该致电:

<script type="text/javascript"><!--
    $('select[name=\'zone_id\']').load('index.php?route=<DIRECTORY>/enroll/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script>

用正确的值切换<DIRECTORY>值...


编辑

  1. 仅使用account/enroll/zone,而不是完整路径
  2. 将该行的条件551

    if ($this->request->post['zone_id'] == '')

    if ($this->request->get['zone_id'] == '')(介意从post->切换get)。


编辑2:

我猜开发团队在重新实现注册表单时搞砸了很多事情......$('#register').submit();就像你的一样没<form ...>问题id="register"。再试一次这个改变:从

if ($this->request->get['zone_id'] == '')

if (isset($this->request->get['zone_id'] == ''))

现在Notice: Undefined index: zone_id不应该发生错误。

于 2013-05-18T00:04:51.243 回答