Not very fond with Liquid code but need help on this…I’d like to write an Else IF statement using liquid code for a section on some products on the site.
If product does not contain “tag” hide section Else show section assigned.
This is the piece of code that is on the template file for the Highlight section on the product page:
{% assign product_tag_string = product.tags | join: ’ ’ | handle | replace: ‘-’, ‘’ %}
{% unless product_tag_string contains ‘hide-highlights’%}
{% comment %} Capturing the content allows us to only output markup if content exists {% endcomment %}
{% capture section_content %}
{% capture display_block_id %}
{% include ‘product-section-display-block-id’, product: product, blocks: section.blocks %}
{% endcapture %}
{% assign display_block_id = display_block_id | plus: 0 %}
{% for block in section.blocks %}
{% assign block_id = block.id | plus: 0 %}
{% if display_block_id == block_id %}
{% assign highlights_tab_id = block.id | append: ‘-highlights-tab’ %}
{% assign highlights_panel_id = block.id | append: ‘-highlights-panel’ %}
{% assign itb_tab_id = block.id | append: ‘-itb-tab’ %}
{% assign itb_panel_id = block.id | append: ‘-tb-panel’ %}
{% if block.settings.highlights != blank or block.settings.in_the_box != blank %}
-
{% if block.settings.highlights != blank %}
- Highlights {% endif %} {% if block.settings.in_the_box != blank %}
- In The Box {% endif %}
{% break %}
{% endif %}
{% endfor %}
{% endcapture %}
{% if section_content != blank %}
{% endunless %}
Not sure if this is going to work to just tell Shopify not to use a section called “highlights” if the product does not have a tag assigned to display on it?
{% unless product_tag != blank%}
Right now having errors on pages that are displaying a random “highlight” section, because Shopify is not reading the assigned tags to those product pages correctly and need a side option that can help for some time while we fix that.