All things Shopify and commerce
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 %}
Solved! Go to the solution
This is an accepted solution.
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 %}
<script>
window.location.href = "URL to the no access page";
</script>
{% endif %}
No sure if this is all I did , but hopefully it helps.
I have tried as well
{% if customer %}
{% if customer.tags contains ‘USWholesale’ %}
<style>
#product_element_id{
display:none;
}
</style>
{% 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.
This is an accepted solution.
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 %}
<script>
window.location.href = "URL to the no access page";
</script>
{% endif %}
No sure if this is all I did , but hopefully it helps.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025