我的服务器上安装了 Magento 1.7.0.0。我面临一个关于可选邮政编码国家的问题。我的意思是我想让爱尔兰的邮政编码可选,为此我在管理面板的可选国家列表中选择了爱尔兰(系统 > 配置 > 常规)。但是当我访问结帐页面并选择爱尔兰时,它会从邮政编码字段中删除一个星号,这很好,但是当我点击继续时,它会显示一个警告框(“邮政编码是必需的值”)。为什么?
请帮我!提前致谢...
问问题
1717 次
2 回答
0
我认为是因为邮政编码输入具有 html 类 required-entry 如果您编辑模板并退出类 js 将不会检查该输入并且不会触发警报。但请记住,仅在爱尔兰使用条件或其他东西来退出这门课。
于 2013-09-26T22:50:02.907 回答
0
短期解决方案
将此添加到您的.document(ready)
. 请注意,等*
是必需的。country_id
billing[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>
然后如果<select>
改变了,检查是否选择了选项hasClass('postcode-required')
。
于 2015-10-29T10:34:53.437 回答