zachharkey
9/22/2016 - 6:19 AM

Liguid logic for displaying specific "ship" messages depending on product tag

Liguid logic for displaying specific "ship" messages depending on product tag

Lead time messages based on tags

Requirements from client

    So the tags are in all caps and the corresponding messages to go with are below each 
    
    SHIP 1 
    1-2 week lead time
    
    SHIP 2 
    2-6 week lead time 
    
    SHIP 3 
    Extended lead time 

Here is the necessary logic in 'liquid' code


{% if product.tags.size > 0 %}
    {% for tag in product.tags %}
      
      {% case tag %}
        {% when 'SHIP 1' %}
          <p class="lead-time mt1 orange">
            1-2 week lead time
          </p>
        {% when 'SHIP 2' %}
          <p class="lead-time mt2 orange">
            2-6 week lead time 
          </p>
        {% when 'SHIP 3' %}
          <p class="lead-time mt1 orange">
            Extended lead time 
          </p>
        {% else %}
           <!-- No message -->
      {% endcase %}

    {% endfor %}
{% endif %}


The above code lives in snippets/lead-time.liquid and is included in product.liquid with {% include 'lead-time' %}. You can edit the code here.

Here's the result