Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello all,
I'm using my phone and I want to display the total number of items placed on the cart page in a certain area as shown in the picture below. I also want it to be shown on desktop.
My store URL: https://u7yeji-na.myshopify.com/cart
Hey there!
If you are comfortable working with liquid in your theme, you could use the cart.item_count (link) field on the cart object.
You have {{ cart.item_count }} cartons of water
If you want specifically a subset for just one type of product, you could loop through your cart items to find the number you want, save it to a variable, and then display that.
{% assign carton_count = 0 %}
{% for item in cart.items %}
{% if item.product.type == "Water" %}
{% assign carton_count = carton_count | plus: item.quantity %}
{% endif %}
{% endfor %}
You have {{ carton_count }} cartons of water.
Hi @deckhand,
Can you walk me through step by step with pics on how I get this done and where should I place the codes exactly? Thank you in advance.