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.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025