0

我目前正在开发 Open Cart 1.5.4 中的一个项目。我将购物车轻微移动到另一个 div 中,没有任何问题。事情是在新电脑上,当他们第一次进入网站时,客户不可能将产品添加到购物车中。如果他们进入另一个页面然后返回它就可以了。javascript文件正确加载,没有任何问题。

希望这个解释很好地解释了问题或错误。

提前致谢。

JAVASCRIPT

function addToCart(product_id, quantity) {
    quantity = typeof(quantity) != 'undefined' ? quantity : 1;

    $.ajax({
        url: 'index.php?route=checkout/cart/add',
        type: 'post',
        data: 'product_id=' + product_id + '&quantity=' + quantity,
        dataType: 'json',
        success: function(json) {
            $('.success, .warning, .attention, .information, .error').remove();

            if (json['redirect']) {
                location = json['redirect'];
            }

            if (json['success']) {
                //$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');

                $('.success').fadeIn('slow');
                try {
                    $('#cart-total').html(json['total']);
                }
                catch(err) {
                    console.log(err.message());
                }

                $('html, body').animate({ scrollTop: 0 }, 'slow');

                $(".heading").animate({backgroundColor: "#FFFFFF"}, 'slow');

                $(".cart_arrow").attr("style", "display: block;");

                $(".heading").animate({backgroundColor: "#585858"}, 'slow');

            }   
        }
    });
}
4

2 回答 2

0

改变

url: 'index.php?route=checkout/cart/add',

url: $('base').attr('href') + 'index.php?route=checkout/cart/add',
于 2013-01-14T11:42:59.430 回答
0

找到了问题的原因。当安装了 Open Cart 并且即将选择域时,您可以选择 www 或非 www。取决于你选择的另一个不会工作。所以解决这个问题的htaccess重定向从非www到www地址

RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [R=301,L]

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

The redirect has to be over RewriteBase /

Thanks and I hope this helps in the future for anyone nedded this kind of support

于 2013-01-25T07:36:14.863 回答