I'm using the default Supply theme for my Shopify store and I've enabled Ajaxify Cart option.
I've customised the theme so that if a customers add Product X to the cart, reloads and hovers over the product (on the collections page) it shows that Product X is added 1 time to the cart.
This is the liquid code that shows the quantity of Product X in the cart:
<!-- Snippet from product-grid-item.liquid -->
{% assign count = 0 %}
{% for item in cart.items %}
{% if product.id == item.product.id %}
{% assign count = count | plus: item.quantity %}
{% endif %}
{% endfor %}
...
<span class="item-quantity">{{ count }}</span>
If a product is in the cart .triangle-top-right
gets added to div#in-cart-indicator
, if it's not in the cart the class is not-in-cart
.
Here's a GIF illustrating what it currently looks like:
![enter image description here][1]
Current situation:
- Add Product X to cart
What happens:
- Cart count get's updated
- Reload the page
What happens:
- The div containing Product X get's a blue triangle in the top right corner, indicating that Product X is in the cart
- When hovering over Product X, it shows the number of times Product X is in the cart.
What I would like:
- Add Product X to cart
What happens:
- Cart count get's updated
- The div containing Product X get's a blue triangle in the top right corner, indicating that Product X is in the cart
- When hovering over Product X, it shows the number of times Product X is in the cart.
I've tried messing with the code in ajaxify.js, but my lack of javascript seems to break things.
What could I try to accomplish this?