【问题标题】:Remove telephone field from Billing Information section in Magento从 Magento 的账单信息部分删除电话字段
【发布时间】:2015-04-14 12:40:45
【问题描述】:

如何从magento帐单信息部分 中删除telephone field。但在运输信息中我需要telephone field。我可以隐藏billing.phtml 文件中的电话号码。但是telephone fieldmandatory 字段。所以我不能点击继续按钮。

我需要shipping Information page 中的telephone 字段(作为必填项)。并且不需要 billing information page 中的 telephone 字段。

我该怎么做?请帮助我...任何帮助都是非常可观的。

【问题讨论】:

  • magentocommerce.com/magento-connect/configurable-checkout.html 我记得这个模块在你的禁用字段中放置了一些默认值在后台
  • SO 不是代码编写服务。如果您有一些代码但无法正常工作,请将其发布,以便我们帮助解决您的问题。
  • @Mark Fitzgerald,我不要求提供代码,但我需要建议或帮助来了解如何操作。如果我为一页(计费)更改某些内容,则会影响另一页(shippig)。这就是为什么我在这里发布问题。以下链接表示常见情况:swarminglabs.com/…

标签: php magento shipping billing


【解决方案1】:

最终的解决方案包含三个步骤:

  1. 删除客户端 (javascript) 验证 如果它们在您的主题中尚不存在,请将以下文件从基本/默认主题复制到您的主题: template/checkout/onepage/billing.phtml
    在每个文件中,查找定义电话字段的 并从标签中删除所需的类,从输入中删除所需的属性类并确保删除 *。

  2. 重新定义Mage_Customer_Model_Address_Abstract 类 将文件 app/code/core/Mage/Customer/Model/Address/Abstract.php 复制到 app/code/local/Mage/Customer/Model/Address/Abstract.php 。这可确保升级不会破坏您的修改。现在打开文件并查找它验证电话字段的部分,它应该看起来像这样:

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

    您可以完全删除此部分,也可以将其放在/**/ 之间将其注释掉。

  3. 更改数据库中的客户 EAV 打开表eav_attribute 并搜索带有attribute_code = “telephone” 的行。记下这一行的attribute_id。接下来,将列 is_required 设置为 0(零)。
    现在,打开表 customer_eav_attribute 并搜索与您在上一步中记下的 attribute_id 相同的行。将此行上的列validation_rules 设置为NULL。

【讨论】:

  • @JIGNESH,这将删除计费和运输页面中的电话验证。我只需要从结算页面中删除它。
  • 您可以在前端使用 magento 类验证送货电话。 css 类:input-text required-entry
【解决方案2】:
app->code->core->mage->Eav->Model->Attribute->Data->Text.php

不要更改数据库表………… 你在 Text.php 文件中改变了.. 我提到了 Path ....

改变这个:

if ($attribute->getIsRequired() && strlen($value) == 0)
{
   $errors[] = Mage::helper('eav')->__('"%s" is a required value.', $label);
}

到:

if ($attribute->getIsRequired() && strlen($value) == 0)
{
if($label != 'Telephone')
    {
        $errors[] = Mage::helper('eav')->__('"%s" is a required value.', $label);
    }
}

【讨论】:

    【解决方案3】:

    您可以使用 GoMage LightCheckout 扩展程序,它是一个单页结帐解决方案,具有许多有用的选项,其中一个选项是能够对字段进行排序或删除不需要的字段。因此,您可以使用该扩展程序的管理面板设置禁用电话号码字段。

    【讨论】:

      【解决方案4】:

      app->code->core->mage->Eav->Model->Attribute->Data->Text.php

      不要在数据库表中更改……可以在Text.php中更改,请为它创建一个本地副本,意味着核心文件编辑在magento中不是一个好习惯,所以在app/code/local中创建一个文件夹/Mage/Eav/Model/Attribute/Data/Text.php

      更改这些行:

      if ($attribute->getIsRequired() && strlen($value) == 0)
      {
         $errors[] = Mage::helper('eav')->__('"%s" is a required value.', $label);
      }
      

      对这些:

      if ($attribute->getIsRequired() && strlen($value) == 0)
      {
      if($label != 'Telephone')
          {
              $errors[] = Mage::helper('eav')->__('"%s" is a required value.', $label);
          }
      }
      

      还有

      更改这些行:

      $validateRules = $attribute->getValidateRules();        
                      if (!empty($validateRules['min_text_length']) && $length < $validateRules['min_text_length']) {
                          $v = $validateRules['min_text_length'];
                          $errors[] = Mage::helper('eav')->__('"%s" length must be equal or greater than %s characters.', $label, $v);
                      }
                      if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']) {
                          $v = $validateRules['max_text_length'];
                          $errors[] = Mage::helper('eav')->__('"%s" length must be equal or less than %s characters.', $label, $v);
                      }
      

      收件人:

      $validateRules = $attribute->getValidateRules();
              if($label != 'Telephone')
                  {
                      if (!empty($validateRules['min_text_length']) && $length < $validateRules['min_text_length']) {
                          $v = $validateRules['min_text_length'];
                          $errors[] = Mage::helper('eav')->__('"%s" length must be equal or greater than %s characters.', $label, $v);
                      }
                      if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']) {
                          $v = $validateRules['max_text_length'];
                          $errors[] = Mage::helper('eav')->__('"%s" length must be equal or less than %s characters.', $label, $v);
                      }
                  }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-21
        • 2019-02-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-05
        相关资源
        最近更新 更多