Conditional message based on items tag present in cart for shopify

Topic summary

Goal: Show a cart warning in Shopify when customers add items with different size tags (A–E).

Initial implementation: The OP used Liquid to set flags for tags A–E and display a warning when Size A appears with any other tag. They sought a cleaner approach and mentioned confusion with “unless”.

Update: A helper provided a simplified Liquid snippet that increments a counter for items containing any of the size tags and displays a warning if more than one item qualifies. The OP confirmed it works.

Enhancement request: The OP asked to list the specific sizes in the warning. The helper shared code to gather item.product.tags, split them, and render a message listing sizes with “and”. The OP noted it includes all product tags, not just size tags, and asked if filtering to only size tags is feasible.

Next steps: The helper requested collaborator access or email to review the theme code for a refined solution. The OP will invite after theme work and agreed to proceed via collaborator/email.

Status: Partial solution achieved; filtering to show only size tags and accurately listing sizes remains open. Code snippets are central to the discussion. Liquid is Shopify’s templating language used to inspect product tags.

Summarized with AI on December 20. AI used: gpt-5.

Hi Namphan,

Thank you for your fast response. That code looks awesome and did the trick, but it shows all the tags associated to that product. Not just the size tag. Is this something achievable or should i just use your first code which is already great ?

Regards,