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.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024