Display Message Based On Product Tag on Shopify

Suppose when sales happening on specific SKU's. It's better to convey to customers a proper message on the product page

so the first step needs to tag the product with a specific name if you installed apps like https://matrixify.app/ will help to import easily with tags exchange. otherwise, you have to do with normal Shopify export & import.

on product-template.liquid or on some theme its product-default-template.liquid
add this below code

{% for tag in product.tags %}
   {% if tag == "Flash Sale" or tag == "deal-ofthe-day"%}
          <span>⚠️ Coupon Codes not Applicable, Already at Best Price.</span><br/>
   {% endif %}  
   {% if tag == "sample"%} 
          <span><img class="limit2-svg-icon"> Limited Purchase Quantity</span><br>
          <span>⚠️ Coupon Codes not applicable, Already at best price</span><br/>
   {% endif %}             
{% endfor %}

Suppose scenarios like when you want to add the message which is on offer, and without offer tag as a different message, here is the example

{% for tag in product.tags %}
   {% if tag == "Freedom"%} 
     {% assign freedom_tag = tag %}
   {% endif %}
{% endfor %} 

{% if freedom_tag %}
   Buy 4 Pay for 2 - Use code : <span style="border: 2px dashed #ebcc71; padding: 0 10px 0 
   10px;">FREEDOM</span><br/>
{% else %}
   <span>⚠️ Buy 4 Pay for 2 Not Applicable</span><br/>
{% endif %}

Here is the scenario when you want to run offer freebies only for a few SKU's, and want to display a message with steps and  option to add free product cart

{% if tag == "SOME-TAGS" %}
 <img class="offer-svg-icon"> GET <a href="#" style="color:#F58148">IMMUNITY BOOSTER 
 </a>FREE ON PURCHASE OF WORTH ₹999. <br>
 <span style="color:#456639"> HOW TO AVAIL OFFER: </span><br/> 1️⃣ Add <SOME TAGS> 
 Products Worth ₹999 & above.<br/> 
 2️⃣ Add Free Product to Cart 
 <form action="/cart/add" method="post" class="variants" 
 id="-4526022393969" data-id="product-actions-4526022393969" enctype="multipart/form- 
 data">
  <input type="hidden" name="id" value="31858861539441"> 
  <button type="submit" data-form-id="#-4526022393969" style="color: #fff;
    background-color: #F6A300;
    border-radius: 4px;">Click Here
  </button>
 </form>
 3️⃣ Use Code <span class="coupon-box">FREE3FWD</span> at checkout.<br/> 4️⃣ Enjoy your 
 Order.
{% endif %}  

In the above code

Product ID: 4526022393969

Variant ID: 31858861539441

Did you find this article useful?