Realtime cart total update (minus specific item amount)

Hello,

I am attempting to update the cart-subtotal__price element on the cart page in real time, minus the amount of a subscription item (which is offered at 100% off for the first month). I am adjusting the subtotal amount with liquid (subtracting out the subscription monthly price), but whenever any item is removed or any item's quantity is changed, the subtotal is overwritten with the TOTAL price (INCLUDING the subscription trial price I'd like to be reflected as zero). Examples:

Screen Shot 2021-04-13 at 12.14.06 AM.pngScreen Shot 2021-04-13 at 12.16.13 AM.png

 

I would like the second screenshot's subtotal to say "$23.97", as it does when I refresh. I'm guessing this is updating through JS/AJAX/fetch, but that's where I'm not so strong. Any advice on what I can specifically do to keep the total updated in realtime, regardless of what updates happen on that page?

For reference, I'm subtracting the product price off the subtotal for any line item with a specific tag (in this case the recurring subscription product that is on offer).

Thanks!

Trash Nuts
Supremely Smoked Almonds
0 Likes