2013-01-14 50 views
0

我目前正在開Open Cart 1.5.4的項目中工作。我沒有任何問題輕輕地將購物車轉移到另一個分區。事情是在新電腦上,當他們第一次進入網站時,客戶無法將產品添加到購物車。如果他們進入另一個頁面,然後返回它工作得很好。 JavaScript文件正確加載沒有任何問題。Opencart 1.5.4 addToCart()第一次頁面顯示功能不起作用

希望這個解釋說明問題或bug相當不錯。

在此先感謝。

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'); 

      } 
     } 
    }); 
} 

回答

0

發現問題的原因。當安裝Open Cart並且即將選擇域時,您可以選擇www或非www。取決於你選擇其他的人不會工作。 所以解決問題的htaccess重定向這一個從非www到www ADRESS

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] 

重定向有超過RewriteBase/

謝謝,我希望這有助於在未來的人nedded這種支持

0

變化

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

url: $('base').attr('href') + 'index.php?route=checkout/cart/add', 
+0

感謝您的答案,但它不是真正的問題的原因,最近發現的問題,這是非www域的地址,我扔在一個htaccess文件 – Ziinloader