Hide a product from certain customers

I would like to hide 1 product from customers unless they have a specific customer tag.

So (here’s what I’ve come up with so far)

{%if customer.tags == 'appstle_subscription_active_customer'%}

then I would like this product to show.

But

{%if customer.tags != 'appstle_subscription_active_customer'%}

then I would like the page to redirect to

/pages/members-only

I know there are apps that can do this (like Locksmith) but it seems like I should be able to do this without an app, especially since it’s just one product.

Could anyone assist me with this?

1 Like

Hi @ksecondo ,

If you would like to hide the product to certain customers, you have to do it in several places. This could be a little confusing if you do not have coding experience. You are in the right track though, you would use an if statement for this.

You have to check if the customer is logged in first, so then you are able to check if the customer contain some tags.

You have to initially hide the product, wherever this product is, and display block only if it meets the criteria


{% if customer %}
{% if customer.tags != 'appstle_subscription_active_customer'%}

{% endif %}
{% endif %}

you are so kind to respond. Thank you! So would this go in the .json file of the product page template?

And I i wanted to have the page redirect to another page if the customer is not allowed access, could I do something like this:


{% if customer %}
{% if customer.tags != 'appstle_subscription_active_customer'%}

{% else%}

{% endif %}
{% endif %}

Hi @ksecondo

Depending on what theme you are using. You should be able to wrap your product template with the if statement.

Thanks! I ended up including this code in the product-template.liquid file and it worked like a charm:

{% if template contains 'hidden' %}
        {% if customer %}
            {% if customer.tags contains 'appstle_subscription_active_customer' %}
                {{ content_for_layout }}
            {% else %}
                
            {% endif %}
        {% else %}
                
        {% endif %}
    {% else%}
        {{ content_for_layout }}
    {% endif %}

Hi

Hello,

I would need customers to not be able to access certain product categories when searching. These categories of products are only available to professional customers who have an access code to access them. But the products are still visible in the search results of my non-professional clients.

Is there a solution for the search mask?

Thanks for your help

Hi!!

do you know how to hide products from all countries except the usa?

The product-template.liquid file no longer exists. I only see the product.json and the main-product.liquid files that might even come close. Please provide an updated solution. Thanks very much!

Hi @ksecondo , this YouTube video has a solution for restricting specific products or pages on your Shopify store: