Post by jonathan88 » Thu Apr 20, 2017 5:44 pm

OpenCart version 2.3.0.2

I have added a form with a google recaptcha to a module which I have displayed on my home page only, the form and the module appear to be working fine, it's just this notice for the google recaptcha that's annoying me now. The recaptcha appears to work fine.

Code: Select all

Notice: Undefined index: route in /home/dolphdes/public_html/catalog/controller/extension/captcha/google_captcha.php on line 18
This is line 18 of the google_captchat.php file, which is:

Code: Select all

$data['route'] = $this->request->get['route']; 
Naturally, I am assuming that the error is not in this file but in the module controller file or template file for my customised module.

I lifted the form pretty much directly from the contact page files, making use of the contact us language file as well.

Code: Select all

<!-- Contact form --!>
      <div id="contact-form" class="home-contact-form">
        <div class="home-contact-form">
          <form action="" method="post" enctype="multipart/form-data" class="form-horizontal">
            <fieldset>
              <legend><?php echo $text_contact; ?></legend>
              
              <div class="form-row">
                  <div class="form-group required" id="home-form-name">
                    <label class="col-sm-2 control-label" for="input-name"><?php echo $entry_name; ?></label>
                    <div class="col-sm-10">
                      <input type="text" name="name" value="<?php echo $name; ?>" id="input-name" class="form-control" />
                      <?php if ($error_name) { ?>
                      <div class="text-danger"><?php echo $error_name; ?></div>
                      <?php } ?>
                    </div>
                  </div>
                  <div class="form-group required" id="home-form-email">
                    <label class="col-sm-2 control-label" for="input-email"><?php echo $entry_email; ?></label>
                    <div class="col-sm-10">
                      <input type="text" name="email" value="<?php echo $email; ?>" id="input-email" class="form-control" />
                      <?php if ($error_email) { ?>
                      <div class="text-danger"><?php echo $error_email; ?></div>
                      <?php } ?>
                    </div>
                  </div>
              </div>         
              <div class="form-row">
                  <div class="form-group required" id="home-form-enquiry">
                    <label class="col-sm-2 control-label" for="input-enquiry"><?php echo $entry_enquiry; ?></label>
                    <div class="col-sm-10">
                      <textarea name="enquiry" rows="5" id="input-enquiry" class="form-control"><?php echo $enquiry; ?></textarea>
                      <?php if ($error_enquiry) { ?>
                      <div class="text-danger"><?php echo $error_enquiry; ?></div>
                      <?php } ?>
                    </div>
                  </div>
              </div>
              <div id="captcha">
                <?php echo $captcha; ?>
              </div>              
            </fieldset>
            <div class="buttons">
              <div class="pull-right">
                <input class="btn btn-primary" type="submit" value="<?php echo $button_submit; ?>" />
              </div>
            </div>
          </form>
        </div>
      </div>
<!-- End contact form --!>
I added in bits from the contact us controller file to the module controller file as well, interspersed with the existing code.

The module was an existing Testimonial one which works fine (after I made a few tweaks, it had a few bugs in the admin side not related to the form and also customised it for my own needs), it displays a testimonial on the left with a form on the right. I see no reason why these two things shouldn't be able to exist in a single module, they share the index function in the controller, the only problem is with the recaptcha. I would have made them two separate modules but couldn't see a way to lay them side by side on a single row using the existing OpenCart page layout design.

Any help with what might bring on such a notice? I've looked online and found stuff relevant to forms made as part of the home page or information pages but not as a module on the home page, I don't know if that would make a difference, none of it helped. I'm sure it's just something silly that I've missed.

Thank you in advance.

Newbie

Posts

Joined
Thu Apr 20, 2017 5:16 pm

Post by artcore » Thu Apr 20, 2017 8:15 pm

Code: Select all

$data['route'] = isset($this->request->get['route']) ? $this->request->get['route'] : ''; 
Home doesn't have a route set per se which is why it will trigger the error

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by jonathan88 » Thu Apr 20, 2017 10:36 pm

Ah! Thank you so much, I replaced the line

Code: Select all

$data['route'] = $this->request->get['route']; 
in catalog/controller/extension/google_captcha.php with your suggestion and it cleared the notice. Brilliant!

Newbie

Posts

Joined
Thu Apr 20, 2017 5:16 pm

Post by artcore » Thu Apr 20, 2017 10:55 pm

Excellent! And welcome to the forum btw ;D

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by zmeia_moy » Mon Apr 01, 2019 4:22 am

Hi there, I have the same problem but with this code that i whant to implment in my feature.php:
Error is:

Code: Select all

Notice: Undefined index: route in catalog/controller/product/fastorder.php on line 86
This is line 86 of the feature.php file, which is:

Code: Select all

$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
I try to implement this code

Code: Select all

'fastorder'   => $this->load->controller('product/fastorder', $product_info = $this->model_catalog_product->getProduct( isset($result['product_id']) ? $result['product_id'] :'' )), // FastOrder
on line after

Code: Select all

'rating'      => $rating,
Can someone help me with thise?
Thank you in advance.

Newbie

Posts

Joined
Thu Feb 22, 2018 4:45 am

Post by graphix_shiv » Sat Aug 01, 2020 9:14 pm

artcore wrote:
Thu Apr 20, 2017 8:15 pm

Code: Select all

$data['route'] = isset($this->request->get['route']) ? $this->request->get['route'] : ''; 
Home doesn't have a route set per se which is why it will trigger the error
Thank you mate. It woked brilliantly :-)

Newbie

Posts

Joined
Wed Jul 01, 2020 12:58 pm
Who is online

Users browsing this forum: No registered users and 126 guests