Magento – Checkout saveBilling generates error due to extractData method not working properly

errormagento-1.7onepage-checkoutvalidation

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?

Best Answer

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.

Related Topic