【问题标题】:Make Postal Code un required for Ireland in Magento在 Magento 中使爱尔兰不需要邮政编码
【发布时间】:2015-10-29 21:20:55
【问题描述】:

我的服务器上安装了 Magento 1.7.0.0。我面临一个关于可选邮政编码国家的问题。我的意思是我想让爱尔兰的邮政编码为可选,为此我在管理面板的可选国家列表中选择了爱尔兰(系统 > 配置 > 常规)。但是当我访问结帐页面并选择爱尔兰时,它会从邮政编码字段中删除一个星号,这很好,但是当我单击继续时,它会显示一个警告框(“邮政编码是必需的值”)。为什么?
请帮我!提前谢谢...

【问题讨论】:

  • 您将主题实现与基本主题进行比较。前端相关代码是带有 shippingRegionUpdater 的 JavaScript 代码。处理所有相关的标签和输入。

标签: magento


【解决方案1】:

我认为是因为邮政编码输入具有 html 类 required-entry 如果您编辑模板并退出类 js 将不会检查该输入并且不会触发警报。但请记住,仅针对爱尔兰使用条件或其他内容来退出该课程。

【讨论】:

    【解决方案2】:

    短期解决方案

    将此添加到您的.document(ready)。请注意,* 是必需的,因为您有 country_idbilling[country_id] 等。

    function require_postcode_check(){
        jQuery('select[name*=country_id]').each(function(){
            jQuery(this).closest('form').find('input[name*=postcode]').toggleClass('required-entry', jQuery(this).val() != 'IE');
        });
    }
    require_postcode_check(); // execute on document ready
    jQuery('select[name*=country_id]').on('change', function(){
        require_postcode_check(); // execute on country change
    });
    

    长期解决方案

    一个长期的解决方案是为每个需要邮政编码的<option> 设置一个类:

    <option value="UK" class="postcode-required">United Kingdom</option>
    <option value="IE" class="">Ireland</option>
    

    那么如果&lt;select&gt;改变了,检查选中的选项hasClass('postcode-required')是否。

    【讨论】:

      猜你喜欢
      • 2011-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      • 2020-06-09
      • 1970-01-01
      相关资源
      最近更新 更多