Now in OpenCart 3.0 and 2.3.0.1 version, it is very easy to setup google reCaptcha in multiple pages. Forms of Opencart that google reCaptcha supported are Register, Guest Checkout, Reviews, Returns, and Contact.
Basic Captcha:
Go to Extensions >> Extensions >> In Choose the extension type >> Captchas (2)
Now click the green button to install the Basic Captcha
Click the blue edit button of Basic Captcha
Choose Enabled from the status
Click save and you are set
Google reCaptcha:
Go to Extensions >> Extensions >> In Choose the extension type >> Captchas (2)
Now click the green button to install the Google reCaptcha
Click the blue edit button of Google reCaptcha
How to set it up in Google reCaptcha admin?
Go to https://www.google.com/recaptcha/admin (login with Gmail account if not) and enter your Label(Any name) and domain name(website URL). New style with reCAPTCHA v3: After entering the label select the reCAPTCHA type "reCAPTCHA v2" and then select "I'm not a robot" Checkbox" and in the Domain, enter your domains name
Old style:
When you click the register button, you will get the site key and secret key in the Keys tab. New style: Old style
Same mistake. The version is the same. The solution does not work. Could you help me?
Thanks!
Agoston
P
Paul
•
Hello Rupak,
Thanks for the reply. Yes I double checked I have all exact the same coding in the contact.php. Actually I refreshed the module modification and it works now. Not sure if were related but I am glad it is resolved. Thanks you for great help and excellent site.
Cheers!
R
Rupak Nepali
•
Hi @Paul,
In catalog/controller/information/contact.php you can find the code implemented in the validate method.
==================
protected function validate() {
if ((utf8_strlen($this->request->post[‘name’]) < 3) || (utf8_strlen($this->request->post[‘name’]) > 32)) {
$this->error[‘name’] = $this->language->get(‘error_name’);
}
if (!filter_var($this->request->post[’email’], FILTER_VALIDATE_EMAIL)) {
$this->error[’email’] = $this->language->get(‘error_email’);
}
if ((utf8_strlen($this->request->post[‘enquiry’]) < 10) || (utf8_strlen($this->request->post[‘enquiry’]) > 3000)) {
$this->error[‘enquiry’] = $this->language->get(‘error_enquiry’);
}
// Captcha
if ($this->config->get($this->config->get(‘config_captcha’) . ‘_status’) && in_array(‘contact’, (array)$this->config->get(‘config_captcha_page’))) {
$captcha = $this->load->controller(‘extension/captcha/’ . $this->config->get(‘config_captcha’) . ‘/validate’);
if ($captcha) {
$this->error[‘captcha’] = $captcha;
}
}
return !$this->error;
}
==================
Please verify yout secret key and site key again.
P
Paul
•
Hi,
Thanks for the sharing. I have an issue with OC 2.3.0.2. After enabled with google recaptcha and applied to the contact form but it doesn’t work. I can see the google captcha “I am not Robot” appear but it simply doesn’t work and bypass it no matter you have authenticating it or not. Do you have any idea? I have checked the catalog/controller/information/contact.php the google reCaptcha seems no code applying in there. Can you help please?