Updating Cart Icon without refreshing when cart is empty

I am trying to change the shopping cart icon whenever the cart is empty. However, I need to refresh the page to see the change.
I made the if loop saying if cart.item_count is equal to 0, my source image will load.

<a href=“{{ routes.cart_url }}” class=“Heading u-h6” {% unless template == ‘cart’ or settings.cart_type == ‘page’ %}data-action=“open-drawer” data-drawer-id=“sidebar-cart” aria-label=“{{ ‘header.navigation.open_cart’ | t }}”{% endunless %}> {% if cart.item_count == 0 %} {% endif %}

So the image loads but it needs to load without refreshing the page. How do I make this happen? Thanks

1 Like

Hello, @dhsk11

Welcome to the Shopify community!
and Thanks for your Good question.

Please share your site URL,
So I will check and provide a solution here.

also, can you try this

https://community.shopify.com/c/Shopify-Design/Product-pages-Stay-on-the-product-page-after-adding-products-to/td-p/616440