0

我无法从产品视图 (template/catalog/product/view.php) 在购物车中添加东西?数量为 0,如果您更改为更高的数字,您仍然无法将其添加到购物车......</p>

演示:http ://eldeskin.com/magento/index.php/ansiktskrem.html

在其他论坛上阅读ALOT后,错误可能是JavaScript错误引起的。我使用了 Safari 错误控制台,发现 js/prototype/prototype.js 中有错误

TypeError:'undefined' 不是函数(评估:'element.dispatchEvent("on" + actualEventName, responder)') TypeError:'undefined' 不是函数(评估:'element.dispatchEvent(event)')

4

1 回答 1

2

我的钱花在这个上:您的页面来源中有这个:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
// Using jQuery.

$(function() {
    $('#form-search').each(function() {
        $(this).find('input').keypress(function(e) {
            // Enter pressed?
            if(e.which == 10 || e.which == 13) {
                this.form.submit();
            }
        });

        $(this).find('input[type=submit]').hide();
    });
});
</script>

jQuery 与原型冲突。包含 js 文件后需要添加jQuery.noConflict(),对于任何使用 jQuery 的函数,请勿使用$. 它应该是这样的:

jQuery(function() {
    jQuery('#form-search').each(function() {
        jQuery(this).find('input').keypress(function(e) {
            // Enter pressed?
            if(e.which == 10 || e.which == 13) {
                this.form.submit();
            }
        });
        jQuery(this).find('input[type=submit]').hide();
    });
});

编辑
至于数量,问题不在于javascript。在数量框中,默认显示后端库存选项卡中产品上设置的最小销售数量的值。将其设置为 1,它应该可以解决您的问题。

于 2013-10-03T19:47:37.213 回答