Why does my product page appear empty after applying a customer tag filter?

Dear all,

I have been trying to find a solution but not too sure as I have not seen a solution that works.

I am trying to lock a product from being viewed by everyone other than those who are tagged.
I have created a product.US-Wholesale.liquid with below code the same way I locked my collections. But when I go into the product, the product page is blank.

Any work around this.

{% if template contains ‘US-Wholesale’ %}
{% if customer %}
{% if customer.tags contains ‘USWholesale’ %}
{{ content_for_layout }}

{% else %}
{% render ‘wholesale-note’ %}
{% endif %}

{% else %}
{% render ‘wholesale-note’ %}
{% endif %}

{% else %}
{{ content_for_layout }}
{% endif %}

I have tried as well

{% if customer %}
{% if customer.tags contains ‘USWholesale’ %}

#product_element_id{ display:none; }

{% endif %}
{% endif %}

@YogaBear hi,

I think your first condition is disturbing page.

I think i’ve figured it out, trying on multiple products.
Will update once if it works for all.

@YogaBear what is the basic work you want to perform with this code

Have you figured it out?! I’m having the same problem.

I wanted to block out the products under a specific collection from others who can access the product via direct url.

So what I did was to copy main-product.liquid (Under Section) and create a new section called main-product-(collection name).

and pasted this in the top
{% if customer.tags contains ‘Your Customer Tag’ %}

<section id="MainProduct-{{ section.id }}" class="page-width section-{{ section.id }}-padding" data-section="{{ section.id }}"

and this after /section

{% else %}

{% endif %}

No sure if this is all I did , but hopefully it helps.