2011-02-11 107 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') ?>"); 
    }); 
});