How can I access cart items in javascript for the ajax cart?

How can I access cart items in javascript for the ajax cart?

walliby
Visitor
2 0 0

Hello, I have added the below logic to my cart based on the item vendors as follows. This code works fine for the regular cart page but I also have an ajax cart using code similar to https://github.com/Shopify/Timber/blob/master/snippets/ajax-cart-template.liquid. If I try to add the below code to this template, the items do not update without a hard page refresh. Can anyone tell me how to access the cart items in javascript for the ajax cart, similar to what I've done below? 

 

{% assign isGlobalShipAvailable = true %}
{% for item in cart.items %}
{% if item.vendor == 'SOME_VENDOR' %}
   {% assign isGlobalShipAvailable = false %}
{% endif %}
{% endfor %}

{% if isGlobalShipAvailable  %}
     DO_SOMETHING
{% endif %}
Reply 1 (1)

walliby
Visitor
2 0 0

Well I dug into this some more and I have a better handle on it (no pun intended) but I need to dig into handlebars.js and I think I can make something work.