2011-02-11 41 views
3

我已经尝试了很常用的方法进行注册时不需要电话领域,但它似乎并没有与Magento的1.4.2Magento的1.4.2 - 注册字段不要求

我的工作VE由/的

的Magento /应用/代码/核心/法师/客户/型号/地址复制Abstract.php

的magento /应用程序/代码/本地/法师/客户/型号/地址/ Abstract.php

并除去从验证函数下面的代码在该文件中

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

}

我也从register.phtml文件删除

class="input-text required-entry" 

,但我不能让过去的valida灰。我不断收到错误

“电话”是必需的值。 “电话”长度必须等于或大于1个字符。

感谢

回答

8

默认电话属性设置为数据库中的需要。请参阅is_required列的eav_attribute表,搜索attribute_code = 'telephone'

或者,您可以只运行一次该代码,例如使用安装脚本。

$telephone = Mage::getModel('eav/entity_attribute') 
      ->loadByCode('customer_address', 'telephone') 
      ->setIsRequired(false) 
      ->save(); 

你也需要删除星号*从从你模板从

<label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label> 

checkout\onepage\billing.phtml

变化(线〜120)

<label for="billing:telephone"><?php echo $this->__('Telephone') ?></label> 

删除缓存查看更改。

+0

我第二此方法。安装脚本应该放置在公司名称空间的自己的插件目录中,以便可以在其他安装中重现(例如,如果您移动服务器,托管或将代码升级到舞台/制作) – philwinkle 2011-02-11 17:32:50

6

需要执行几个步骤(版本1.7.0.2)。

  1. 如上所述:改变数据库表eav_attributePhpmyadmin是一个简单的方法来做到这一点。

  2. 评论这些3行:

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

    • App/code/core/Mage/Customer/Model/Address/Abstract.php
    • includes/src/Mage_Customer_Model_Address_Abstract.php
    • includes/src/_checkout.php
  3. 您还可以删除app/design/frontend/base/default/template/persistentapp/design/frontend/base/default/template/customer文件夹的onepage文件夹中的register.phtmlbilling.phtml文件中的*

没有错,Magento真的想让这个必填项!

这应该做到这一点。

0

我知道所有建议的复制和编辑核心文件的解决方案,但这将是升级自杀。

对于现在(Magento 1.9及更早版本),不需要修改Magento核心文件的唯一方法是在电话字段中使用虚拟值。

一个简单的模拟式的解决方案是添加到“地址/ edit.phtml”文件的底部:

jQuery(function($){ 
    $('#form-validate').submit(function(){ 
     var telephone = $('#telephone'); 
     if(!telephone.val().length) 
      telephone.val("<?= $this->__('Not supplied') ?>"); 
    }); 
});