Author Topic: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)  (Read 15194 times)

emtemt

  • Beginner
  • *
  • Posts: 5
After a long search to the forum how to implement joomla captcha to the virtuemart enquiry form I have found a solution myself and wanted to share with you.
It is tested with virtuemart 2.0.26a and it is based in the tutorial I found here: http://blog.plite.org/neo_one2199/2013/04/03/use-joomla-default-recaptcha-plugin-in-your-component-or-module/

first we have to enable captcha plugin from plugin manager and fill it with public and private key that we could create from: http://www.google.com/recaptcha

If you have made template overrides, you have to put the code in the overrided files inside: your_template_name/com_virtuemart/askquestion

in the file: components/com_virtuemart/views/askquestion/tmpl/form.php
after textarea and before submit button we add the code:
<? // captcha addition
   JPluginHelper::importPlugin('captcha');
   $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
?>
   <div id="dynamic_recaptcha_1"></div>
<? // end of captcha addition
?>

in the file:  components/com_virtuemart/views/askquestion/tmpl/mail_confirmed.php
on the top of the page before php tag close we add:
   // captcha addition
   $post = JRequest::get('post');
   JPluginHelper::importPlugin('captcha');
   $dispatcher = JDispatcher::getInstance();
   $res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
   if(!$res[0]){

   $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
   die(JText::_('COM_VIRTUEMART_WRONG_CAPTCHA').'&nbsp;&nbsp;<a href="'.$askquestion_url.'">'.JText::_('COM_VIRTUEMART_BACK').'</a>');
}
   // end of captcha addition

in the file:  language/en-GB/en-GB.com_virtuemart.ini
we add the two new variables:
COM_VIRTUEMART_WRONG_CAPTCHA="The captcha code is wrong, please try again"
COM_VIRTUEMART_BACK="back"

Good luck :)
Emmanuel

[attachment cleanup by admin]

servlet

  • Jr. Member
  • **
  • Posts: 348
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #1 on: January 28, 2014, 12:23:53 pm »
Hello
Thank you for sharing

Pleaste tell me. Is this only for ask a question form. I dont need captcha for registration.
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

emtemt

  • Beginner
  • *
  • Posts: 5
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #2 on: January 28, 2014, 12:42:59 pm »
that's right, only for enquiry form not for registration! :)

servlet

  • Jr. Member
  • **
  • Posts: 348
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #3 on: January 28, 2014, 13:54:37 pm »
Thank you for quick answer.
I sugest this code to be implemented in VM by default
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Your code is not working. There is no validation before sending the email.

I've adapt your code and integrated into the VirtueMart Core with options for ask question, recommend email and registration form. It is available with vm 2.5.2.

emtemt

  • Beginner
  • *
  • Posts: 5
hello again,
I have tested with 2.0.26a and it was working just fine. Maybe it has issues with newer versions but 2.0.26a is for sure ok.
That's nice that you have implemented that to 2.5 by default.

Regards

Pejo

  • Jr. Member
  • **
  • Posts: 64
Yep, I was looking just for this, because only trough this now spam can go trough, but this captcha is not working on my Vm 2.0.24

@kkmediaproduction is it possible to get some code or solution here that is working with current VM version (or at least previous)?
Really need something to stop spamming trough "ask a question about this product".

It started today and it is really annoying. Other forms (registration, contact, etc) are protected with captcha, so it is OK.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10073
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
just vm2.5.2.

You can directly update. It is the RC of vm2.6. The reason we did not released it yet as vm2.6 is just that we need more tests, in special of the captcha. It is more likely that you are doing an error changing the 5 files than just using the latest version.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
hello again,
I have tested with 2.0.26a and it was working just fine. Maybe it has issues with newer versions but 2.0.26a is for sure ok.
That's nice that you have implemented that to 2.5 by default.

Regards

Sure? You have no validation before sending the mail. So if you enter a wrong code, the mail is sending and only for the confirming site is a validation check.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3700
  • using Matomo instead of Google Analytics
Really need something to stop spamming trough "ask a question about this product".
It started today and it is really annoying. Other forms (registration, contact, etc) are protected with captcha, so it is OK.

The ReCaptcha is just one option to prevent spam using the VM 'Ask a question' form. Another one is 'EasyCalcCheck Plus', which is available in the Joomla Extension Directory. 'SpambotCheck' works pretty well, too.

However, at present the devs need some feedback about how ReCaptcha works in VM 2.5.2+
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

ptrouw

  • Jr. Member
  • **
  • Posts: 126
just vm2.5.2.

You can directly update. It is the RC of vm2.6. The reason we did not released it yet as vm2.6 is just that we need more tests, in special of the captcha. It is more likely that you are doing an error changing the 5 files than just using the latest version.

Hi,

You mentioned vm2.5.2 has captcha already. I am running 2.0.26d, should I upgrade a production site to vm 2.5.2?
Is this the next official stable release?
Will it be available shortly within the automatic update service?

kigri

  • Beginner
  • *
  • Posts: 5
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #11 on: February 09, 2015, 23:08:47 pm »
Hello,

I followed all the steps. The captcha appears in the form but when I leave it blank or I enter a wrong code, an email is still sending. Why??
Could anyone help???
I am using virtuemart 2.0.10 and I use captcha in registration and contact form correctly.

Thank you in advance,
kigri

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9887
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #12 on: February 10, 2015, 00:07:26 am »
virtuemart 2.0.10  ??? wildly out of date and unsafe
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3700
  • using Matomo instead of Google Analytics
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #13 on: February 10, 2015, 00:12:37 am »
VirtueMart 2.0.10 was released in 2012. The captcha was implemented in version 2.5.2 in 2014 as stated for example in the post above yours. You should update to one of the latest versions either from here: http://dev.virtuemart.net/projects/virtuemart/files or here: http://virtuemart.net/downloads
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

kigri

  • Beginner
  • *
  • Posts: 5
Re: Captcha in Virtuemart 2 Enquiry Form (Ask a question about this product)
« Reply #14 on: February 10, 2015, 18:10:55 pm »
Thank you very much for your answers!
I installed 2.6.14 and it works!!!
Thanks!!