Item Count in Cart By Collection

2 0 0

I have a sort of unique site that allows franchise locations to load custom artwork and order create a bulk order of assorted apparel with that artwork for their location to resell. They have a request to be able to see total item count by collection in their cart. They can obviously see total cart quantity on the icon in the header, but they want to see a line in the cart for total quantity of a particular collection. Any thoughts on how to accomplish that?

Replies 2 (2)

Shopify Staff
2731 298 769

Hi Kworgan16,


If I'm understanding correctly, you want customers to see, on the cart page, how many items are from which collections. So for example there could be a line saying "5 items from the Winter collection", and "10 items from the Spring collection"? 


On the cart page, Liquid doesn't give you access to collections, so you can't directly match products to collections on the cart page. But you can access metafields, so you could create a new product-based metafield definition that would be text based and the metafield for each product would be the name of it's collection. 


Then you could implement Liquid logic on the cart section file, to to determine the collection of each item, iterate through the cart items, aggregate the totals by collection, and then output the total count for each collection, as Liquid variables. Finally you'd display the numbers and the names of the collections by referencing the Liquid variables, something like:


{% for collection_name, count in collection_counts %}
  <div>{{ count }} products from {{ collection_name }} collection</div>
{% endfor %}

 Would this work for you?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog

2 0 0

Liam, thank you so much for the response! This sounds like it would work and make sense. Although I have 0 coding skills and will need to hire someone to help me out!! I really appreciate the guidance on a solution though!