0

In checkout process when I select either "Checkout as a guest" or "Register" and then fill out the proper form, clicking on the button to go to the next step generates error. This is what the exception is caught:

{"error":-1,"message":"The first name cannot be empty., The last name cannot be empty., Invalid email address \"\"."}

The problem is I am inserting all the fields and when I debug using Firebug, these fields show as validation passed fields. So they pass the proper validation on client side, what could be causing this error then? Some kind of server side validation?

Can anyone please give me some solution for this issue? Why Magento is giving this error when all the fields are properly filled up?

Edit: I have debug the Onepage.php files of both my site as well as default Magento setup. The extractData method is returning an empty array in my site, which is causing error during validation because the fields are missing after the data is extracted. Can anyone please help me out here?

2

After spending lot of time, I got solution for this. If data is not getting from the extractData, you can set the value again for the firstname, lastname, email in app\code\core\Mage\Checkout\Model\Type\Onepage.php. You can copy paste Onepage.php to your local folder add the below lines look like below code.

$customer->setEmail($data['email']); $customer->setFirstname($data['firstname']); $customer->setLastname($data['lastname']);

    if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
        // set customer password
        $customer->setPassword($customerRequest->getParam('customer_password'));
        $customer->setPasswordConfirmation($customerRequest->getParam('confirm_password'));
    } else {
        // spoof customer password for guest
        $customer->setEmail($data['email']); //email
        $customer->setFirstname($data['firstname']); //firstname
        $customer->setLastname($data['lastname']); //lastname
        $password = $customer->generatePassword();
        $customer->setPassword($password);
        $customer->setPasswordConfirmation($password);
        // set NOT LOGGED IN group id explicitly,
        // otherwise copyFieldset('customer_account', 'to_quote') will fill it with default group id value
        $customer->setGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    }

    $result = $customer->validate();`

I hope it will work fine and it will be helpfull for someone.

1

This validation is server side, so either the data isn't passed to the server or it is removed somewhere before the validation.

Check what is passed and if the input fields so have the correct names.

  • the data is posted alright. Still it is not getting validated. – jdhaar Jan 6 '14 at 9:15
  • Then I think the easiest is to hook into the validate Method: \Mage_Eav_Model_Form::validateData and check, what is validated. – Fabian Blechschmidt Jan 6 '14 at 11:34
  • Hi, I hooked into the method that you suggested and in that method the result is returned with proper validation. No errors are generated. I don't know what else to do now. – jdhaar Jan 8 '14 at 4:48
  • You hooked into \Mage_Customer_Model_Customer::validate? This is strange. But then the error comes from somewhere else :-/ – Fabian Blechschmidt Jan 8 '14 at 6:19
  • 2
    I compared my own site files with that of a default Magento setup. This is what is happening. In the file Checkout/Model/Type/Onepage.php the extractData method is not returning anything at all. this is the line for that $customerForm->extractData($customerRequest);. It is returning an empty array in my site whereas in default Magento it returns an array of form fields. – jdhaar Jan 8 '14 at 6:46
1

app\code\core\Mage\Checkout\Model\Type\Onepage.php

comment this line number 384 to 390

$customerErrors = $customerForm->validateData($customerData); if ($customerErrors !== true) { return array( 'error' => -1, 'message' => implode(', ', $customerErrors) ); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.