Removing the validation on onepage checkout in Magento

Removing the validation on onepage checkout in Magento

October 6, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Removing the validation on onepage checkout in Magento

Disabling First Name / Last Name Validation in Magento Onepage Checkout

One of the common challenges faced by Magento store owners is handling customer addresses that don’t require a first name or last name during checkout. By default, Magento enforces these fields, leading to errors if they remain empty. In this post, we’ll guide you through disabling the validation for these two fields in the onepage checkout process.

Understanding the Issue

When a customer proceeds to checkout without providing a first name or last name for their shipping address, Magento will display an error message: “Please check shipping address information. Please enter the first name. Please enter the last name.”

This validation is built into the core of Magento and affects all customers by default. However, there are scenarios where this isn’t necessary, such as when dealing with corporate accounts or specific business models that don’t require these personal details.

Why Disable Validation?

Disabling the validation for first name and last name fields can enhance the checkout experience for certain customer segments:

  1. Faster Checkout: Removing unnecessary fields reduces form complexity, allowing customers to complete their purchases more quickly.
  2. Improved UX for Specific Customers: For corporate accounts or wholesale clients who typically use company names instead of personal ones, a simplified address form is more intuitive.
  3. Reduced Abandoned Carts: By streamlining the checkout process and reducing friction, you can potentially decrease cart abandonment rates.

Steps to Disable Validation

To disable the validation for first name and last name fields in the onepage checkout, we’ll need to modify two core Magento files:

  1. Override the core file
app/code/core/Mage/Checkout/Model/Type/Onepage.php
  1. Add a custom validation exception

In the Mage_Checkout_Model_Type_Onepage class, locate the validateCustomerData() method.

Override the core file

First, create a new module in your Magento installation to override the core file:

mkdir app/code/local/Magento/DisableCheckoutValidation

Then, create the necessary directories and files:

cd app/code/local/Magento/DisableCheckoutValidation/
mkdir etc
mkdir Model
touch etc/config.xml
touch Model/Type/Onepage.php

Add a custom validation exception

Open app/code/local/Magento/DisableCheckoutValidation/Model/Type/Onepage.php in your favorite text editor and add the following code:

<?php
class Magento_DisableCheckoutValidation_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
    public function validateCustomerData()
    {
        $address = $this->getQuote()->getShippingAddress();
        if ($address && !$address->validate()) {
            throw new Exception("Please check shipping address information.");
        }

        // Custom validation exception for first name and last name fields
        if (empty($address->getFirstname()) || empty($address->getLastname())) {
            return true;  // Return true to bypass the error message
        }

        return $this;
    }
}

Configuring Your Module

Now, open app/code/local/Magento/DisableCheckoutValidation/etc/config.xml and add the following configuration:

<?xml version="1.0"?>
<config>
  <modules>
    <Magento_DisableCheckoutValidation>
      <version>0.1</version>
    </Magento_DisableCheckoutValidation>
  </modules>
  <global>
    <models>
      <checkout>
        <rewrite>
          <type_onepage>Magento_DisableCheckoutValidation_Model_Type_Onepage</type_onepage>
        </rewrite>
      </checkout>
    </models>
  </global>
</config>

Compile Your Magento Installation

After updating the files, compile your Magento installation to apply the changes:

php magento compile

Conclusion: Streamline Checkout Experience for Specific Customers

By following this guide, you can effectively disable the validation for first name and last name fields in the onepage checkout process. This customization allows you to cater to specific customer segments that don’t require these personal details during checkout.

Remember to thoroughly test your implementation before deploying it to a live environment. Regularly review and update your code as Magento releases new versions or updates its core files.

If you found this solution helpful, consider exploring other Magento customizations and optimizations on our blog at LaravelCompany.com. We regularly share insights and best practices for improving Magento performance and user experience.

Checkout Customers Errors CLI

Our network