How to auto-apply different discounts to specific product variants at checkout?

Does anyone know of a way to have a partner discount be like the following and have it auto-apply at checkout? It needs to have the textile swatch variant be free and all other products/variants be 20% off. I tried creating two Shopify discount codes that allow discount combinations and have a setup on the cart.liquid to add the codes when the customer is tagged with a certain tag. But I can’t get it to apply both codes when the cart contains products/variants of both discounts. I also tried looping through the cart items to grab the variant option values that are in the cart, but I don’t quite know how to go about that. My logic is if the cart has a product with an option value of “swatch” it will apply the free discount to those products, if the cart has any other variant option values it will apply the 20% discount to those products. Is this possible? Here is the cart code I have:

    {% if customer.tags contains 'from-pifyapp' %}
      {% for item in cart.items %}
        {% for option in item.option_with_values %}
          {% if option.value == "swatch" %}
            <input type="hidden" name="discount" value="TRADEPARTNERS" >
          {% else %}
            <input type="hidden" name="discount" value="TRADEPARTNER" >
          {% endif %}
        {% endfor %}
      {% endfor %}
    {% endif %}

Thank you!