Set up Google reCaptcha or Basic Captcha in OpenCart 3.0+ and 2.3.0.1+

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?
    1. 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:
      google recaptcha for opencart
      After entering the label select the reCAPTCHA type “reCAPTCHA v2” and then select

      Old style:

      google recaptcha for opencart
    2. When you click the register button, you will get the site key and secret key in the Keys tab. New style:
      google recaptcha for opencart
      Old style

       

      OpenCart site key and secret key of google reCaptcha
  • Enter the Site key and Secret key from the google reCaptcha page
    basic-captcha
  • 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 :

captcha-in-page

Choose whichever captcha you want to show in the site and then click save.

Now go to contact us page:

presentation-layer-contactus-captcha

If you get an error like:
ERROR for site owner: Invalid key type

error in google recaptcha for opencart

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.

Previous articleShow images for the sub-categories in the opencart versions 2.3, 3, and 4
Next articleSet Shipping to Selected Countries Only in OpenCart
Author of three Opencart book. The recent Opencart 4 book is at https://amzn.to/4dOlbOR

4 COMMENTS

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

  2. 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!

LEAVE A REPLY

Please enter your comment!
Please enter your name here