How to update cart message with cart actions in real time?

Hey guys,

We have implemented the code attached below on our cart.liquid to add a message to the cart when specific products are added to the basket.

It does work but the problem we have is that the cart message doesn’t update based on adjustments to the cart such as actions like clicking “remove” item so that there are no more items in the basket which have the cart_notice == true.

The message won’t update unless you physically refresh the browser yourself.

Another issue is that if you add to the basket from the collection page using a quick add button, it doesn’t register that product as being in the basket unless you refresh, it. only works properly if you add it directly from the product page.

An example of a product that meets the metafield requirement is “/products/alani-nu-fit-snacks-protein-bar-blueberry-muffin”.

You can preview the theme we’re working on here: https://h34jjgs7gpdfki4s-22594233.shopifypreview.com

How can we get the message at the cart to update/refresh as it should?

{% assign cart_notice = product.metafields.custom.cart_notice %}
  {% if cart_notice == true %}
  
  

  PICK AND MIX 10+ INDIVIDUAL PRODUCTS WHICH HAVE THE {% render 'flair-product-badges', product: item.product, flair_layout: 'Cart Inline' %} TAG FOR UP TO 15% OFF. FULL BOXES ARE ALREADY DISCOUNTED.
  

  

  {% else %}
  

  {% endif %}