2013-04-25 27 views
1

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

+0

你会比较你的主题实现和基本主题。前端相关代码是带有shippingRegionUpdater的JavaScript代码。照顾所有相关的标签和输入。 – 2014-01-10 10:56:47

回答

0

我认为是因为邮政编码输入有html类required-entry如果您编辑模板并退出类js不会检查该输入,并且警报不会被触发。但请记住使用条件或东西来退出这个类只为爱尔兰。

0

短期解决方案

添加到您的.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> 

然后如果更改了<select>,请检查选定的选项hasClass('postcode-required')