Display custom liquid block by variant color

Hello,

I currently have a custom liquid block on our product page that displays when the item will be despatched.

{% capture c_date %}{{'now' | date:'%a' }}{% endcapture %}
{% if c_date == 'Sat' %}

**ORDER TODAY FOR DESPATCH ON MONDAY**

{% elsif c_date == 'Sun' %}

**ORDER TODAY FOR DESPATCH ON MONDAY**

{% else %}

**ORDER BEFORE 3PM FOR SAME DAY DESPATCH**

{% endif %}

I would like to display a different message in the same block for a specific variant colour. In this case we will have a green variant and I would like the block to display “AVAILABLE FOR PRE-ORDER

Does anyone know how I would implement this change? I believe it would be something along the lines of this but I can’t get it to work.

{% assign current_variant = product.selected_or_first_available_variant %}
{%- if current_variant.color contains "green" -%}
<div>
<p><strong>AVAILABLE FOR PRE-ORDER</strong></p>
</div>
{%- else -%}
{% capture c_date %}{{'now' | date:'%a' }}{% endcapture %}
{% if c_date == 'Sat' %}
<div>
<p><strong>ORDER TODAY FOR DESPATCH ON MONDAY</strong></p>
</div>
{% elsif c_date == 'Sun' %}
<div>
<p><strong>ORDER TODAY FOR DESPATCH ON MONDAY</strong></p>
</div>
{% else %}
<div>
<p><strong>ORDER BEFORE 3PM FOR SAME DAY DESPATCH</strong></p>
</div>
{% endif %}
{% endif %}

Any help would be greatly appreciated. Sorry I am quite new to this coding malarkey!

The custom liquid block won’t be able to update the message when a variant is being selected, unless the page is refreshing.
To achieve this you will need either to do it through javascript which is very much related to the theme you’re using, or use metafields for the product’s variant and change/show/hide the message based on the existence of the metafield value.

Hey,

Unfortunately, Shopify doesn’t have a built-in setting for this - you’ll need Liquid code. Your approach is close, but .color isn’t valid. Use product.selected_or_first_available_variant.option1 (or option2/option3, depending on where “Color” sits in your variant setup). Try {% if product.selected_or_first_available_variant.option1 == 'Green' %} to show “AVAILABLE FOR PRE-ORDER”, then fall back to your date logic for others. See Shopify’s custom Liquid guide.

Trade-off: You’ll need to manually update the code each time you add variants with special messaging -no UI option exists natively.

Alternative: Apps like K1 PreOrder automate this (I’m the founder). You can set variant-specific pre-order rules - select your green variant, add your message, done. No code needed for future changes. Here’s the K1 PreOrder listing if relevant.

Happy to help with theme customization if you go the Liquid route.

Best regards,
Yauheni