I’m new to developing on Shopify.. can anyone help with how to ‘listen’ to cart changes and update the UI?
I have this code which will render the checkout button or not depending on the value of the cart_total:
{% if cart.total_price > 15000 %}
{% else %}
Our minimum order value for checkout and shipping is **£150** or more.
Please add some more bottles
{% endif %}
But this only works on page load or refresh..
This code below (that shipped with the default theme) applies a discount to my cart_total based on a discount code I have set up, and the discount is applied adding a span with ‘discount applied’ to the UI (without the need for a refresh or load):
{%- assign cartDiscounts = 'template ' | split: ' ' -%}
{%- if cart.cart_level_discount_applications.size > 0 -%}
{%- assign cartDiscounts = cart.cart_level_discount_applications -%}
{%- endif -%}
As I'm pretty new to liquid and shopify.. I am unable to work out which part of this code above is 'listening' to the updated cart value in order to dynamically apply the discount..
I could make it work by manipulating the DOM with JS and reading values etc.. but that seems very hacky.
Can anyone help?
Many thanks :folded_hands: