Hide Products from Collections based on Tags

New Member
4 0 0

I have been able to hide products from customers who do not have the correct Tag on their account from specific product that has been Tagged.  If they click on the product a friendly warning appears telling them For Administrative Clients Only

This is working with great success.  What I was wondering is there liquid code that would hide those same products from the Collection pages entirely if the customer is not logged into a valid account?  

What I worked out so far was the following code but the logic is incorrect:


   {% for product in collection.products %}

       {% if customer.tags contains 'iProMerger' or customer.tags contains 'RLP-CitizenMerger' %}

              {% if product.tags contains 'iProMerger' or  product.tags contains 'RLP-CitizenMerger' %}

              {% assign displayProduct = true %}

       {% endif %}

  {% else %}

     {% if product.tags contains 'iProMerger' or product.tags contains 'RLP-CitizenMerger' %}

          {% assign displayProduct = false %}

{% endif %}

 {%- include 'bold-product' with product, hide_action: 'skip' -%}

        {% include 'product-grid-item' with grid_item_width %}

      {% else %}

        <div class="grid-item">
          <p>{{ 'collections.general.no_matches' | t }}</p>

{% endif %}

{% endfor %}


Is there anyone who can help me with this?

18 0 1

Does something use the displayProduct variable to display or not display the product?