Creative coding solution

Topic summary

Goal: Switch the cart’s availability message to “available in 5 days” when any item belongs to the “My Wedding To Go” collection; otherwise show “available in 48 hours.”

Key approaches proposed:

  • Loop through cart items, check each product’s collections for the target collection handle, set a boolean flag, and conditionally render the message. The flag can be used directly (no need to compare to true).
  • Use a product metafield to mark relevant products and check that instead of iterating collections; more robust than relying on collection or SKU. Advanced variants: line item properties or cart attributes.
  • Build a JSON list of all collection handles via map filters and test contains ‘“my-wedding-to-go”’ to avoid false matches, reducing explicit loops in the template.

Outcome/update: The author implemented a practical workaround by checking if any item SKU contains “MWTG” (the wedding items’ SKU prefix), which successfully switches the message. They noted confusion when inspecting item.product.collections (unexpected “CollectionsDropCollectionsDrop” output).

Caveats: SKU-based checks can be brittle; strict comparisons or metafields are recommended to avoid false positives/negatives.

Status: Working solution in place; thread offers more robust alternatives for future refinement.

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

I currently have some custom code on my cart-template to display some important info.

  {% if cart.item_count >= 0 %}

                          <SPAN class="availability-notice">Orders can be available in 48 hours.</SPAN>

                          <SPAN class="availability-notice-fineprint">Before checkout you must select; <b>drop-off</b> or <b>pick-up</b> and verify zipcode,<br>then select applicable Date and Time</SPAN>

  {% endif %}

However, “availability-notice” needs to change if any of the items in the cart are from a specific collection called “My Wedding To Go.” The text needs to change to “this order can be available in 5 days” as an example.

Anyone have any creative ideas to make this happen?

Loop over the items and test for the collection to set a flag then use the flag in the condition
e.g. show_availability_notice → {% if show_availability_notice and cart.item_count >= 0 %}

{% liquid
  # © 2025 PaulNewton https://community.shopify.com/u/paulnewton
assign availability_notice_collection_handle = "SPECIFIC-COLLECTION-HANDLE"
assign show_availability_notice = false

for item in cart.items
    for collection in item.product.collections
     if item.product.collections.handle == availability_notice_collection_handle
       assign show_availability_notice = true
       break
     endif
     if show_availability_notice
       break
     endif
endfor
%}

You just need to add a conditional check inside the cart template that detects whether any item belongs to the ‘My Wedding To Go’ collection. Once that condition is met, the message auto-switches to your custom text.

If you want, I can show you the exact Liquid logic and where to place it.

I think that’s pretty much what Paul is describing above. He’s suggesting I need to loop through the items to determine if any are in the collection. Then as you describe, I just take the flag and use it to display the correct message for the cart.

{% if show_availability_notice == true %}
Orders can be available in 5 days.
{% else %}
Orders can be available in 48 hours.
{% endif %}

If you have a shorter way, yes please share. I like options.

Thanks Daniel.
It seemed like it SHOULD work, and wasn’t giving me any error, so after a bit of trouble-shooting, I went with {% if item.sku contains ‘MWTG’ %} as MWTG is used in any of the wedding item SKUs. This worked so thanks for getting me there.

FWIW, the output of item.product.collections was “CollectionsDropCollectionsDrop” not sure what that is all about, but SKU works, just wanted to share what happened.

It only needs to be {% if show_availability_notice %} you do NOT need to compare it, it’s already a boolean of true/false

Set a metafield on the products, then check the metafield.
Then check those instead of needing the subloop to check every collection a product might be in.
Or it’s more advanced you’d need to set a line item property on the items themselves, or a cart attribute, then check those.
etc exercises left to the reader.

It has to be looped over, and even if it acted like tags you need to do strict comparisons for this stuff.
or you risk getting false positives, or false negatives such in the case of missing/different skus.

Joining for more options – do not really need to loop:

{% assign all_cart_collections =  cart.items 
   | map: 'product' 
   | map: 'collections' 
   | map: 'handle' 
   | json 
%}
{% if all_cart_collections contains '"my-wedding-to-go"' %}
  . . . 
{% else %}
 . . .
{% endif %}

Using json filter and having quotes in apostrophes in if avoids false positives/negatives.