Magento名字不能为空,电子邮件地址无效

时间:2014-08-07 11:34:03

标签: magento checkout billing

结账时出现错误:

"名字不能为空。,无效的电子邮件地址""。这些字段已填满!

public function validate()
{
    $errors = array();
    if (!Zend_Validate::is( trim($this->getFirstname()) , 'NotEmpty')) {
        $errors[] = Mage::helper('customer')->__('The first name cannot be empty.');
    }

    if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) {
       $this->setLastname();
    }

    if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
         $errors[] = Mage::helper('customer')->__('Invalid email address "%s".', $this->getEmail());
    }

    $password = $this->getPassword();
    if (!$this->getId() && !Zend_Validate::is($password , 'NotEmpty')) {
        $errors[] = Mage::helper('customer')->__('The password cannot be empty.');
    }
    if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array(6))) {
        $errors[] = Mage::helper('customer')->__('The minimum password length is %s', 6);
    }
    $confirmation = $this->getConfirmation();
    if ($password != $confirmation) {
        $errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
    }
    $entityType = Mage::getSingleton('eav/config')->getEntityType('customer');
    $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'dob');
    if ($attribute->getIsRequired() && '' == trim($this->getDob())) {
        $errors[] = Mage::helper('customer')->__('The Date of Birth is required.');
    }
    $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'taxvat');
    if ($attribute->getIsRequired() && '' == trim($this->getTaxvat())) {
        $errors[] = Mage::helper('customer')->__('The TAX/VAT number is required.');
    }
    $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'gender');
    if ($attribute->getIsRequired() && '' == trim($this->getGender())) {
        $errors[] = Mage::helper('customer')->__('Gender is required.');
    }

    if (empty($errors)) {
        return true;
    }
    return $errors;
}

请帮帮我..

0 个答案:

没有答案
相关问题