2016-04-20 151 views

回答

0

一種方法是將您的添加到購物車的代碼,以便您添加產品,然後成功購物車。 Shopify AJAX API頁面顯示一個簡單的例子。

jQuery.post('/cart/add.js', $('form[action="/cart/add"]').serialize()); 

如果你想測試成功,那麼這樣的:

jQuery.ajax({ 
    url:'/cart/add.js', 
    dataType:'json', 
    method:'POST', 
    data:$('form[action="/cart/add"]').serialize()}). 
done(function(jR){ 
    if(jR.status) alert(jR.message); 
    else location.href = '/cart'; 
}); 
相關問題