How to disable the CAPTCHA validation in the product reviews in OpenCart 2.x
We already talked about the benefits of having customer reviews on your store. OpenCart has nice review functionality which includes CAPTCHA validation. However, if you want to get more reviews, you should consider removing the validation since this saves time for the customers. Keep on reading if you want to know how you can accomplish that by using the new OCMod functionality in OpenCart 2.0.
In this article we will show you another tip on how to make your OpenCart more customer-friendly. Last time we talked about how to display price of an item as FREE instead of 0.0. Now we will introduce you another trick, which will disable the CAPTCHA code check in the review submission for the products in your store. This time the core editing of the files will be skipped and we will go straight to using OCMod to implement the modification.
What you have to do is to open your favorite text editor and paste the following code:
<modification> <name>Disable captcha code for the reviews</name> <version>1.0 (Initial)</version> <link>https://isenselabs.com</link> <author>iSenseLabs</author> <code>isenselabs_disable_captcha_reviews</code> <file path="catalog/controller/product/product.php"> <operation> <search><![CDATA[if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {]]></search> <add position="before"><![CDATA[/* disabled check]]></add> </operation> <operation> <search><![CDATA[if (!isset($json['error'])) {]]></search> <add position="before"><![CDATA[disabled check */]]></add> </operation> </file> <file path="catalog/view/theme/*/template/product/product.tpl"> <operation> <search><![CDATA[<div class="col-sm-12"> <img src="index.php?route=tool/captcha" alt="" id="captcha" /> </div>]]></search> <add position="replace"><![CDATA[]]></add> </operation> <operation> <search><![CDATA[<label class="control-label" for="input-captcha"><?php echo $entry_captcha; ?></label>]]></search> <add position="replace"><![CDATA[]]></add> </operation> <operation> <search><![CDATA[<input type="text" name="captcha" value="" id="input-captcha" class="form-control" />]]></search> <add position="replace"><![CDATA[]]></add> </operation> </file> </modification>
When you copy the code above, name the file like this - namebyyourchoice.ocmod.xml. As a rule of thumb, keep in mind that the .ocmod.xml extension is mandatory if you want OpenCart to correctly apply your modification.
When you are all set with the file, open your store administration and navigate to Extensions -> Extension Installer. After that, click “upload the file” using the upload button and wait for the success message.
You are half-way through. The file is uploaded, but not implemented. You should navigate to Extensions -> Modifications and click on the Refresh button. The page will refresh and you should receive another success message. The modification is now implemented and ready to use.
The final result should be something similar to this one:
Note: Keep in mind that CAPTCHA is mainly used to prevent automated software (also called bots) from performing actions on behalf of actual humans. When you disable this functionality, you increase the chance of getting more unsolicited emails.
Let us know if you have ideas for future articles in the comments section below.