I'm trying to make an alert for when a total price in a cart is over $100.
I used a simple if statement, and when the condition is met, show alert. Below is my code inside the HTML (I'm modifying Shopify's theme).
<script>
function showAlert() { alert('You triggered an alert!'); }
</script>
{% if cart.total_price > 100 %}
<script>showAlert();</script>
{% endif%}
This is close, but not quite what I want. It only shows the alert after I refresh the page. I want the alert to show right when the cart hits $100. So, when I add a product and it totals to over $100, I want the alert to show right away. How do I do this?