Skip to content

Problem with Icon Cart Quantity of products #44

Discussion options

You must be logged in to vote

Hey, thanks for the star!
The issue happens because the data-ajax-cart-bind-state attribute doesn't run you liquid expression {% if cart.item_count == 0 %}hidden{% endif %} after the cart is changed. So solution here is using the js-ajax-cart-empty and js-ajax-cart-not-empty classes:

<button 
	type="button" 
	data-ajax-cart-toggle-class-button="js-my-cart-open"
	class="relative">
	<div class="absolute -top-3.5 -right-3">
		(<span class="my-cart-counter {% if cart.item_count == 0 %}my-cart-counter--originally-hidden{% endif %}" data-ajax-cart-bind-state="cart.item_count">
			{{ cart.item_count }}
		</span>)
	</div>
	{% render 'icon-shopping-bag' %}
</button>
.my-cart-counter--originally-hi…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mircomartin
Comment options

@EvgeniyMukhamedjanov
Comment options

@mircomartin
Comment options

Answer selected by mircomartin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants