Post by n19bmw » Mon Sep 27, 2010 12:00 am

Bumpity Bump Bump.

As stated above
I can't sem to get treppo's fix to work on my products page. Sure it does display fine but I cannot get it to sumbit any information and display a success message (this does work fine on the contact page).
This works great on the contact page and does not work on the product review portion. Any ideas??? I was able to get it to display the Recaptcha however it does not look at the test typed to validate the review. Any ideas on how to get this to work ... I am running 1.4.9.1

Here is the working contact page
http://www.briansaudio.net/index.php?ro ... on/contact

Here is the non working product page
http://www.briansaudio.net/index.php?ro ... duct_id=72
Click the review tab.


Any help would be greatly appreciated.

Thanks

Visit http://www.briansaudio.net for all you home electronics needs.


User avatar
Newbie

Posts

Joined
Tue Aug 03, 2010 9:38 am

Post by fubofo » Mon Sep 27, 2010 4:02 am

Still the same issue, nobody has replied with any advice on this (which seems to be a recurring thing with Opencart forums/support unfortunately).

I'm still stuck with it working on the Contact page, but not the Products page.

...Also your Products page doesn't actuallt display the Recaptcha image (at least on my PC using Firefox).
[nicely redesigned btw]

Check through the site I'm currently working on, it does display correctly on Products page in all browsers but I just cannot seem for the life of me to get it to work correctly - I'm not even sure where it is failing (ie not POSTing , not checking validation, not getting a success return, etc...)

http://www.mytilesandbaths.co.uk/shop

I will, at some point when I have the time, read through the Recaptcha and some PHP to see if I can spot anything that stands out. Or failing that, go get help from some PHP forum as confidence in this forum is slowly dwindling.

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by espc » Mon Sep 27, 2010 4:10 pm

i tested it on 1.4.9 and it works great in both pages contact and reviews..strange..

God, give me courage to do what I can,
humility to admit what I can't,
and wisdom to know the difference.

Opencart mods (search suggestions and so on):
http://forum.opencart.com/viewtopic.php?p=71588#p71588" onclick="window.open(this.href);return false;


User avatar
Active Member

Posts

Joined
Fri Dec 04, 2009 12:40 am

Post by fubofo » Mon Sep 27, 2010 5:07 pm

espc wrote:i tested it on 1.4.9 and it works great in both pages contact and reviews..strange..
espc can you let us have a look at your Products page (or take us through how you fixed this?

Thanks

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by espc » Mon Sep 27, 2010 5:56 pm

I simply used treppo's code.

God, give me courage to do what I can,
humility to admit what I can't,
and wisdom to know the difference.

Opencart mods (search suggestions and so on):
http://forum.opencart.com/viewtopic.php?p=71588#p71588" onclick="window.open(this.href);return false;


User avatar
Active Member

Posts

Joined
Fri Dec 04, 2009 12:40 am

Post by fubofo » Mon Sep 27, 2010 6:13 pm

espc wrote:I simply used treppo's code.
Where abouts in the product.php page did you paste the code:

Code: Select all

// RECAPTCHA
if (isset($this->request->post['recaptcha_response_field'])) {
$this->data['captcha_response'] = $this->request->post['recaptcha_response_field'];
} else {
$this->data['captcha_response'] = '';
}

if (isset($this->request->post['recaptcha_challenge_field'])) {
$this->data['captcha_challenge'] = $this->request->post['recaptcha_challenge_field'];
} else {
$this->data['captcha_challenge'] = '';
} 
Could you post the contents of your product.php page here so we can have a look through it?

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by espc » Mon Sep 27, 2010 7:19 pm

it's the same of treppo's

God, give me courage to do what I can,
humility to admit what I can't,
and wisdom to know the difference.

Opencart mods (search suggestions and so on):
http://forum.opencart.com/viewtopic.php?p=71588#p71588" onclick="window.open(this.href);return false;


User avatar
Active Member

Posts

Joined
Fri Dec 04, 2009 12:40 am

Post by fubofo » Mon Sep 27, 2010 8:26 pm

For some reason I cannot seem to find the code:

Code: Select all

 if (isset($this->request->post['captcha'])) {
         $this->data['captcha'] = $this->request->post['captcha'];
      } else {
         $this->data['captcha'] = '';
      }
.....in catalog/controller/product.php

What is the URL of your site with the working ReCaptcha in Products/Review page?

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by espc » Mon Sep 27, 2010 8:36 pm

yes the code changed...
look for this:

Code: Select all

		if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
			$this->error['message'] = $this->language->get('error_captcha');
		}

God, give me courage to do what I can,
humility to admit what I can't,
and wisdom to know the difference.

Opencart mods (search suggestions and so on):
http://forum.opencart.com/viewtopic.php?p=71588#p71588" onclick="window.open(this.href);return false;


User avatar
Active Member

Posts

Joined
Fri Dec 04, 2009 12:40 am

Post by fubofo » Mon Sep 27, 2010 9:17 pm

espc wrote:yes the code changed...
look for this:

Code: Select all

		if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
			$this->error['message'] = $this->language->get('error_captcha');
		}
Sorry espc that is the final step to take in treppo's instructions - I have completed this successfully. The problem I am having is in the very first step:
treppo wrote:In catalog/controller/product/product.php
find

Code: Select all

         if (isset($this->request->post['captcha'])) {
             $this->data['captcha'] = $this->request->post['captcha'];
          } else {
             $this->data['captcha'] = '';
          }
and change it to

Code: Select all

          // RECAPTCHA
          if (isset($this->request->post['recaptcha_response_field'])) {
             $this->data['captcha_response'] = $this->request->post['recaptcha_response_field'];
          } else {
             $this->data['captcha_response'] = '';
          }      
          
          if (isset($this->request->post['recaptcha_challenge_field'])) {
             $this->data['captcha_challenge'] = $this->request->post['recaptcha_challenge_field'];
          } else {
             $this->data['captcha_challenge'] = '';
          }

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by n19bmw » Tue Oct 19, 2010 7:33 am

Has any one had any success with this on the products page. If so please post your code or email it to me.

Any help would be appreciated, Thanks in advance...

O0

Visit http://www.briansaudio.net for all you home electronics needs.


User avatar
Newbie

Posts

Joined
Tue Aug 03, 2010 9:38 am

Post by fubofo » Tue Oct 19, 2010 7:51 am

lol yeah good luck with that one n19bmw. Doesn't seem to be much help anywhere around the fourms, I for one have given up

Newbie

Posts

Joined
Wed Aug 04, 2010 8:30 pm

Post by vang » Wed Oct 27, 2010 2:37 pm

Well, I can get it to show up on the Product review tab, but the problem that I'm running into is the success response.
Without it functioning properly, it won't post the review.

for some reason this code will not work for a pass or fail response. It will work on the contact page, but not the product review page.

Code: Select all

    	if (!$this->recaptcha()) {
             $this->error['captcha'] = $this->language->get('error_captcha');
           }
I dunno. Maybe someone with more experience can solve this problem?
Please!??

http://www.aboveclothing.com


New member

Posts

Joined
Mon May 11, 2009 8:22 am


Post by coolnalu@hotmail.com » Wed Jan 12, 2011 4:50 am

i got it working...somewhat tricky. hope it can help solve ppl's problems.

product.php

FIND

Code: Select all

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
ADD the following code BEFORE it:

Code: Select all

      
// RECAPTCHA
      if (isset($this->request->post['recaptcha_response_field'])) {
        $this->data['captcha_response'] = $this->request->post['recaptcha_response_field'];
      } else {
        $this->data['captcha_response'] = '';
      }

      if (isset($this->request->post['recaptcha_challenge_field'])) {
        $this->data['captcha_challenge'] = $this->request->post['recaptcha_challenge_field'];
      } else {
        $this->data['captcha_challenge'] = '';
      }
REPLACE the old captcha() function with the following function. (it's the same as ppl posted before but put it here for the integrity of the steps.)

Code: Select all

  private function recaptcha() {
    /*    recaptchalib.php needs to be in system/library/ */
    $this->load->library('recaptchalib');

    // Get a key from https://www.google.com/recaptcha/admin/create
    $privatekey = "YOUR PRIVATE KEY";

    # the response from reCAPTCHA
    $resp = null;
    # the error code from reCAPTCHA, if any
    $error = null;

    # was there a reCAPTCHA response?
    if ($this->request->post['recaptcha_response_field']) {
      $resp = recaptcha_check_answer ($privatekey,
      $_SERVER["REMOTE_ADDR"],
      $this->request->post['recaptcha_challenge_field'],
      $this->request->post['recaptcha_response_field']);
       
      if ($resp->is_valid) {
        return TRUE;
      } else {
        return FALSE;
      }
    } else {
      return FALSE;
    }
    return FALSE;
  }
then FIND

Code: Select all

    if (!$this->request->post['rating']) {
      $this->error['message'] = $this->language->get('error_rating');
    }
ADD the following code AFTER it

Code: Select all

    if (!$this->recaptcha()) {
      $this->error['message'] = $this->language->get('error_captcha');
    }
SAVE product.php.

open product.tpl
replace

Code: Select all

              <input type="text" name="captcha" value="<?php echo $captcha; ?>" autocomplete="off" />
              <?php if ($error_captcha) { ?>
              <span class="error"><?php echo $error_captcha; ?></span>
              <?php } ?>
              <br />
              <img src="index.php?route=information/contact/captcha" /></td>
with the following

Code: Select all

 <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YOUR PUBLIC KEY"></script>
   <noscript>
        <iframe src="http://www.google.com/recaptcha/api/noscript?k=YOUR PUBLIC KEY" height="300" width="500" frameborder="0"></iframe><br/>
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
   </noscript>
</td>
next replace old javascript review() function (near the bottom of the file)

Code: Select all

function review() {
  //...omitted.
}
with

Code: Select all

function review() {
	var dataObj = {
		'name' : encodeURIComponent($('input[name=name]').val()), 
		'text' : encodeURIComponent($('textarea[name=text]').val()),
		'rating' : encodeURIComponent($('input[name=rating]:checked').val() ? $('input[name=rating]:checked').val() : ''),
		'recaptcha_response_field' : encodeURIComponent($('input[name=recaptcha_response_field]').val()),
		'recaptcha_challenge_field' : encodeURIComponent($('input[name=recaptcha_challenge_field]').val()),
	};
	$.ajax({
		type: 'POST',
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		data : dataObj,
		dataType: 'json',
				beforeSend: function() {
			$('.success, .warning').remove();
			$('#review_button').attr('disabled', 'disabled');
			$('#review_title').after('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#review_button').attr('disabled', '');
			$('.wait').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review_title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=name]').val('');
				$('textarea[name=text]').val('');
				$('input[name=rating]:checked').attr('checked', '');
				$('input[name=recaptcha_response_field]').val('');
			}
		}
	});
}
product review is submitted differently from inquiries...i.e. via ajax so the form data needs to be added to the ajax request, otherwise they won't be submitted and the validation would constantly fail because it had nothing to check.


Posts

Joined
Wed Jan 12, 2011 4:29 am

Post by booz11 » Wed Jan 26, 2011 12:16 am

coolnalu,

looks like when i try your solution i always get an error for the recaptcha validation during the review submission, even when i am entering in the captcha code right (i tried it plenty of times just to make sure, and even the handicapped version just in case)...still can't get a successful review posted. any ideas?

Newbie

Posts

Joined
Wed Jan 26, 2011 12:07 am

Post by coolnalu@hotmail.com » Wed Feb 16, 2011 11:16 am

booz11 wrote:coolnalu,

looks like when i try your solution i always get an error for the recaptcha validation during the review submission, even when i am entering in the captcha code right (i tried it plenty of times just to make sure, and even the handicapped version just in case)...still can't get a successful review posted. any ideas?
maybe post some code? hard to debug with pure imagination...


Posts

Joined
Wed Jan 12, 2011 4:29 am
Who is online

Users browsing this forum: No registered users and 151 guests