Why isn't my cart message updating with cart adjustments?

Hey guys,

We have added the code copied below on our cart.liquid to show a message to the cart when specific products are added to the basket.

It is working 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. Even when there are no items in the basket at all.

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” if you need to test it on the preview.

You can see the preview 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 %}

Hi @George_Greenhil ,

Please send me the product link showing this, I will check it for you.

1 Like

Hey @LitCommerce

Thanks so much for getting back to me on this.

As it’s a non-published theme, I don’t think I can send page links to a specific pages but I will add the slug and explain how to get to one product for you.

Preview link: https://ya1erww5xrq64vok-22594233.shopifypreview.com

Exact URL (when I open this link it opens our old/live theme for some reason): https://h34jjgs7gpdfki4s-22594233.shopifypreview.com/collections/alani-nu/products/alani-nu-fit-snacks-protein-bar-blueberry-muffin

If that link above doesn’t work and loads our old theme, to navigate to that product from the main preview link, you’d go MAIN MENU > BRANDS > A > ALANI NU > ALANI NU FIT SNACKS PROTEIN BAR BLUEBERRY MUFFIN.

Thanks,

George

Hi @George_Greenhil .

I tried adding that product to cart and it shows no message. Can you explain more about it?

I will check it.

Hey @LitCommerce

I have attached a video showing you it in action. The issue we have is:

  1. The message only shows when you stay on the product page after adding to the cart. If there’s an item with the true metafeild in the basket, it should show up no matter if you’re on a homepage, collection page, product page, blog etc.

  2. If you remove all items from the cart with the metatag as true, the message still shows up in the cart (obviously this is only if you’re on a product page currently due to issue 1) when it should disappear (it does disappear if you hard refresh but we want to avoid making customers do that).