Force donation purchasable to replace donation of the same amount in cart
Anywhere you have a add donation to cart form, you could check if the donation is in the cart and update it instead:
{% set cart = craft.commerce.carts.cart %}

&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;commerce/cart/update-cart&quot;&gt;
    {{ csrfInput() }}
    {% if cart.lineItems %}
        {% set donation = cart.lineItems|first %} &lt;!-- since we know only the donation is in the cart --&gt;
        &lt;input type=&quot;hidden&quot; name=&quot;cartUpdatedNotice&quot; value=&quot;Donation updated.&quot;&gt;
        &lt;input type=&quot;hidden&quot; name=&quot;lineItems[{{ donation.id }}]&quot; value=&quot;{{ donation.id }}&quot;&gt;
        &lt;input id=&quot;donation-amount&quot; type=&quot;text&quot; name=&quot;lineItems[{{ donation.id }}][options][donationAmount]&quot;
               value=&quot;{{ donation.options.donationAmount }}&quot; placeholder=&quot;10&quot;&gt;
        &lt;input type=&quot;submit&quot; value=&quot;Update Donation&quot;/&gt;
    {% else %}
        &lt;input type=&quot;hidden&quot; name=&quot;cartUpdatedNotice&quot; value=&quot;Donation added.&quot;&gt;
        &lt;input type=&quot;hidden&quot; name=&quot;purchasableId&quot; value=&quot;{{ craft.commerce.donation.id }}&quot;&gt;
        &lt;input id=&quot;donation-amount&quot; type=&quot;text&quot; name=&quot;options[donationAmount]&quot; value=&quot;&quot; placeholder=&quot;10&quot;&gt;
        &lt;input type=&quot;submit&quot; value=&quot;Add Donation&quot;/&gt;
    {% endif %}
&lt;/form&gt;