Shopify.onItemAdded update #cart and cart.item.count

前端 未结 1 538
长发绾君心
长发绾君心 2021-01-26 10:17

I\'m trying to make a ajaxed shopping cart in Shopify. I have made the product page add an item to cart without refreshing or going to the cart page. To see cart, you can click

1条回答
  •  没有蜡笔的小新
    2021-01-26 10:59

    This might not be exactly what you need but it may help. I have made and implemented an ajax cart on a shopify site I develop for. I use jquery & JSON to do this type of stuff and here's what I do:

    jQuery.getJSON('/cart.js', function (cart, textStatus) {
      //the cart info is in the callback. the item_count is available as part of the callback
      //below I set my cartcount div with the current cart item_count
      var carttext=cart.item_count;
      jQuery("#cartcount").text(carttext);
    });
    

    0 讨论(0)
提交回复
热议问题