Developer forum

Forum » Swift » Show unique product count in cart instead of total quantity

Show unique product count in cart instead of total quantity

Ferri Halfhide
Reply

Hi Team,

I have the following question: Right now, the number displayed next to the cart icon shows the total quantity of all items in the cart.

Example (current behavior):

  • 200 × Product X

  • 100 × Product Y

    👉 The cart counter shows 300

Desired behavior:

We want the cart counter to show the number of unique products, not the total quantity.

Example (desired):

  • 200 × Product X

  • 100 × Product Y

    👉 The cart counter should show 2, since there are two different products in the cart.

Does anyone know the best approach to modify this logic / or what template so that it counts unique products instead of total quantities? (Swift V1)

Kind Regards, 
Ferri


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

In Swift v2 you change this template:

https://github.com/dynamicweb/Swift/blob/main/Files/Templates/Designs/Swift-v2/Swift-v2_MiniCart.cshtml

Form using @Model.Cart.TotalProductsCount to use @Model.Cart.ProductsCount

In Swift 1 it is this template:

https://github.com/dynamicweb/Swift/blob/v1.26.8/Swift/Files/Templates/Designs/Swift/Swift_MiniCart.cshtml

Votes for this answer: 1

 

You must be logged in to post in the forum