Re: Product page empty

Solved

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

YogaBear
Excursionist
34 2 5

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 %}





Accepted Solution (1)
YogaBear
Excursionist
34 2 5

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. 

View solution in original post

Replies 6 (6)

YogaBear
Excursionist
34 2 5

I have tried as well

{% if customer %}
{% if customer.tags contains ‘USWholesale’ %}
<style>
#product_element_id{
display:none;
}
</style>
{% endif %}
{% endif %}

ProtoMan44
Shopify Partner
640 55 97

@YogaBear  hi,

I think your first condition is disturbing page.

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!

YogaBear
Excursionist
34 2 5

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

ProtoMan44
Shopify Partner
640 55 97

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

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!
msbubbles
Visitor
1 0 0

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

YogaBear
Excursionist
34 2 5

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.