How can I use AJAX to dynamically set quantity of a particular item?

Shopify Partner
2 0 0

The simple function of discounting shipping rates is not available to lower-level Shopify plans, so I am trying to create a work around using shipping weights.

I have a Free + shipping item that I would like to discount. Regular customers pay $8 for shipping. I would like to present an opportunity where customer can get $2 off that. So I have a product that I will call a magic coupon that has negative weight. When added to cart it counters the weight of the weighted item. 

I have figured out how to stop people from editing the number while inside the cart using liquid.

                  <div class="grid__item one-third text-center">
                    {% if item.product.title contains '20 OFF' and item.quantity > 0 %}
  						{% assign newquantity = 1 %}
                    	<input type="number" disabled="disabled" name="updates[]" id="updates_{{ }}" class="cart__product-qty" value="{{ newquantity }}" min="0" {{ bold_qty_attr }}>
					{% else %}
                    	<input type="number" name="updates[]" id="updates_{{ }}" class="cart__product-qty" value="{{ item.quantity }}" min="0" {{ bold_qty_attr }}>
					{% endif %}

But I need to change the actual item.quanity so it passes over to the checkout page. How can I set the quantity of this coupon so that it equals the sum of all free items in my cart?

In this example, I would want the item.quantity of the coupon to be equal to 13...

22 0 4

Can you post your solution here?