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
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
- 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
- Enter the Site key and Secret key from the google reCaptcha page
- Choose Enabled for the Status
- Click save and you are set.
Activate in forms:
Go to Admin >> System >> Settings >> Edit the Store >> Click on Option tab >> Near the bottom you will see the Captcha section :
Choose whichever captcha you want to show in the site and then click save.
Now go to contact us page:
If you get an error like:
ERROR for site owner: Invalid key type
Then please check whether your domain is added correctly or not. Another problem is whether you are using reCAPTCHA v2 or not.
Let us know through comment or email at webocreation.com@gmail.com if you are having any issues.
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?
Thanks,
Paul
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.
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!
Hello,
Same mistake. The version is the same. The solution does not work. Could you help me?
Thanks!
Agoston