0
votes

I need to have users login on the checkout page, without refreshing the page. I setup a login pane, and with ajax I send to the server and authenticate them. But - after this login process, when the user completes the rest of the checkout form, there's an error saying:

Validation error, please try again. 
If this error persists, please contact the site administrator.

Otherwise, when I login, and then refresh the page and only then submit the checkout form - no problem. I assume when refreshing the page ubercart does some stuff that I'm missing in order for the checkout to complete successfully... What are these stuff?

EDIT: ok, so i poked around. found these two functions:

uc_cart_checkout_form_validate

uc_cart_checkout_form_submit

I've done some tests and found out _validate is invoked, but _submit doesn't get invoked! How can that be?

EDIT2: ok, so i discovered that something is setting a validation error, but i can't figure out what. i completely commented out all the code in uc_cart_checkout_form_validate and i double checked that there aren't any other validation functions associated with the checkout forms.

in the beginning of uc_cart_checkout_form_validate i check the session variables and there's an error. who put it there???

using drupal 6, ubercart 2

1

1 Answers

0
votes

if anyone happens to get to this question and wonders what's the answer, i got it:

when an anonymous user fills the checkout form there is no $_REQUEST['form_token']. for an authenticated user - there is!

so anyway the problem was that when i log in a user in the checkout form and try to submit - when the form is created there is no form token, but when the form is submitted there's a logged in user - so drupal looks for a form token and can't find one. that's why the form doesn't validate.

anyway the solution for me was to add this to _form_alter:

if ($form_id == 'uc_cart_checkout_form') {
    unset($form['#token']);        
}