how to add 1 free product to cart without removing the others that are the same

Hi, so i’ve found some code which adds an item of my choosing to the cart when cart value > 50. But when i want to add more of those products i place in for free it always resets back to 1.

FE: Product A cost 10 euros each. When i add 6 of them to my cart it should show one as free while the others remain. At the moment it resets the quantity back to 1 abd shows it as free.

Could someone take a look at the code below and help me with this?

Kind regards,

Ruben

{% assign product = all_products['geschenkbon-5-euro'] %}

{% unless cart.item_count == 0 or product.empty? or product.variants.first.available == false %}

  {% assign variant_id = product.variants.first.id %}

  

{% endunless %}