Remove lastname validate in checkout

overwrite Mage_Sales_Model_Quote_Address

<?xml version="1.0"?>
<config>
    <modules>
        <Empire_Sales>
            <version>1.0.0.0.0</version>
        </Empire_Sales>
    </modules>

    <global>
        <models>
            <sales>
                <rewrite>
                    <quote_address>Empire_Sales_Model_Quote_Address</quote_address>
                </rewrite>
            </sales>
        </models>
    </global>
</config>

  File: /app/code/local/Empire/Sales/Model/Quote/Address.php

<?php 

class Empire_Sales_Model_Quote_Address extends Mage_Sales_Model_Quote_Address
{
    /**
     * Validate address attribute values
     *
     * @return bool
     */
    public function validate()
    {
        $errors = array();
        $helper = Mage::helper('customer');
        $this->implodeStreetAddress();
        if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the first name.');
        }

        if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the street.');
        }

        if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the city.');
        }

        if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
            //$errors[] = $helper->__('Please enter the telephone number.');
        }

        $_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
        if (!in_array($this->getCountryId(), $_havingOptionalZip) && !Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the zip/postal code.');
        }

        if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the country.');
        }

        if ($this->getCountryModel()->getRegionCollection()->getSize()
               && !Zend_Validate::is($this->getRegionId(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter the state/province.');
        }

        if (empty($errors) || $this->getShouldIgnoreValidation()) {
            return true;
        }
        return $errors;
    }
} 

 

 

你可能感兴趣的:(validate)