How can I merge data entires?

Hello!
I got a cart full of items, for example: item1, item2, item3.

If I press the add to cart button once, it added to the database, like:
item1
item2
item3

But if i press it again it add them seperatedly like
item1
item2
item3
item1

How can I make it to work like not to make a new entry but just increase the quantity?

1 Like