How to integrate text with Cart API?

Highlighted
New Member
1 0 0

I am trying to update some text in the same way the cart count is automatically updated through the Cart API but I'm not sure where to begin

In this example below based on the conditional I want "Item" or "Items" to change without refreshing the page

<span class="cart-count{% if cart.item_count == 0 %} hide{% endif %}">
(<span data-cart-count>{{ cart.item_count }}</span>{% if cart.item_count > 1 %} <span>ITEMS</span>{% else %} <span>ITEM</span>{% endif %})
</span>

Any suggestions?

0 Likes