Magento 1

Changing & Fixing Required Customer Fields

Sometimes, a Magento owner may decide that certain customer fields which were optional should now be compulsory. This can break the OPC for customers who registered before this time who are trying to check out. Magento will validate their customer object during the billing section of the OPC, and throw an error (that in our case “Prefix is a required value”).

To fix this, we can copy the information from the customer’s default billing address.

The validation takes place in the Mage_Checkout_Model_Type_Onepage class, in the _validateCustomerData method:

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



Overriding the Onepage Model

class Brandoutlet_Config_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage{
	protected function  _validateCustomerData(array $data){
		// Copy over the prefix from the default billing address.
		// It looks like prefix was made compulsory at some point, so this makes
		// Accounts saved before this was done throw an error at the OPC.
		$customer = $this->getQuote()->getCustomer();
			if($billingDefault = $customer->getDefaultBillingAddress()){
		return parent::_validateCustomerData($data);