IE8中的Magento产品页面:添加到购物车的增量默认值,忽略数量字段.Form.js第266行错误


Magento product page in IE8: add to cart increments by default value, ignoring quantity field. form.js line 266 errors

默认的form.js文件似乎是错误的,当"添加到购物车"被点击。这将阻止正确传递数量字段的值。Magento代替默认值。这个脚本不会出错,数量字段在其他浏览器中也能正常工作。

此外,当我切换回默认主题时,添加到购物车按钮可以正常工作。你知道我该从哪里开始吗。这里有什么不适合IE8的地方吗?我没有修改任何添加到购物车的函数,也没有修改form.js文件。

更新:我有一个browserstack帐户。调试显示VarienForm是未定义的,抛出两个"'productAddToCartForm'是null或不是一个对象"错误。定义VarienForm的Form.js被加载到header中,所以它应该可以用于内联JS。

因为你看不到行号,这里是有问题的行:

this.regionSelectEl.options.add(option);

函数如下:

update: function()
{
    if (this.regions[this.countryEl.value]) {
        var i, option, region, def;
        def = this.regionSelectEl.getAttribute('defaultValue');
        if (this.regionTextEl) {
            if (!def) {
                def = this.regionTextEl.value.toLowerCase();
            }
            this.regionTextEl.value = '';
        }
        this.regionSelectEl.options.length = 1;
        for (regionId in this.regions[this.countryEl.value]) {
            region = this.regions[this.countryEl.value][regionId];
            option = document.createElement('OPTION');
            option.value = regionId;
            option.text = region.name.stripTags();
            option.title = region.name;
            if (this.regionSelectEl.options.add) {
                this.regionSelectEl.options.add(option); //***this is line 266***
            } else {
                this.regionSelectEl.appendChild(option);
            }
            if (regionId==def || (region.name && region.name.toLowerCase()==def) ||
                (region.name && region.code.toLowerCase()==def)
            ) {
                this.regionSelectEl.value = regionId;
            }
        }
        if (this.disableAction=='hide') {
            if (this.regionTextEl) {
                this.regionTextEl.style.display = 'none';
            }
            this.regionSelectEl.style.display = '';
        } else if (this.disableAction=='disable') {
            if (this.regionTextEl) {
                this.regionTextEl.disabled = true;
            }
            this.regionSelectEl.disabled = false;
        }
        this.setMarkDisplay(this.regionSelectEl, true);
    } else {
        if (this.disableAction=='hide') {
            if (this.regionTextEl) {
                this.regionTextEl.style.display = '';
            }
            this.regionSelectEl.style.display = 'none';
            Validation.reset(this.regionSelectEl);
        } else if (this.disableAction=='disable') {
            if (this.regionTextEl) {
                this.regionTextEl.disabled = false;
            }
            this.regionSelectEl.disabled = true;
        } else if (this.disableAction=='nullify') {
            this.regionSelectEl.options.length = 1;
            this.regionSelectEl.value = '';
            this.regionSelectEl.selectedIndex = 0;
            this.lastCountryId = '';
        }
        this.setMarkDisplay(this.regionSelectEl, false);
    }

区域选择应该只在购物车或结帐时触发。检查你的模板是否在skin/frontend/your_theme/js中使用了自己的JS-Files。我认为你的模板是为不同的Magento版本制作的,所以你的html文件中的css选择器不再适合JS了。所以你要么使用匹配JS-Files,要么将你的产品模板与基本模板中的产品模板进行比较,并调整CSS类。