If product tag XX show text otherwise show default text. Product page

I have a text saying Free Shipping - Free Returns on the product page, however, I want to add a code to say Free Shipping - Final Sale if the product is tagged “Sale”.

I know I need to use {% if product.tags contains ‘Sale’%}, but I don’t know how to say show X if tagged otherwise show Y.

How do I do it?

Thank you!

Hi @dmitry_z ,

This is Victor from PageFly - Landing page builder, I’d like to suggest this idea:

{% if product.tags contains 'Sale' %}
  Free Shipping - Final Sale
{% else %}
  Free Shipping - Free Returns
{% endif %}

In this code, the {% if %} statement checks whether the product has the tag “Sale.” If it does, then the text “Free Shipping - Final Sale” will be displayed. Otherwise, the text “Free Shipping - Free Returns” will be displayed.

Hope my answer will help you.

Best regards,

Victor | PageFly

Hi @PageFly-Victor it worked perfectly! Thank you

Is there a way to add 3 options? If tag:X show X // If tag:Y show Y // else Z?

Hi @dmitry_z

Yes, you can use multiple {% if %} statements to check for different conditions and display different text accordingly. Here’s an example of how you can modify your code to show different options based on the product tags:

{% if product.tags contains 'X' %}
  Free Shipping - X
{% elsif product.tags contains 'Y' %}
  Free Shipping - Y
{% else %}
  Free Shipping - Z
{% endif %}

You can modify the tags and text as needed to fit your specific use case.

Thank you so much!!! :raising_hands: