Hide Products Based on Customer Tag

Topic summary

Goal: Restrict certain products so only customers with the “vip” tag can see them. Current issue: products in a VIP-only collection still appear in search and remain accessible via direct URL.

Proposed theme changes (Liquid = Shopify’s templating language):

  • Search results: Edit search.liquid (or search-results.liquid) to loop through search.results, detect if each product belongs to the VIP collection (e.g., handle “vip-products”), and skip rendering those items unless customer.tags includes “vip”.
  • Product page access: In product.liquid, detect if the product is in the VIP collection and, if the customer lacks the “vip” tag, redirect (e.g., to /collections/all) or display an “Access Restricted” message.

App-based alternative: Use a locking/access-control app for greater robustness and less maintenance, e.g., Locksmith, Customer Accounts Concierge, or Wholesale Club, which handle edge cases automatically.

Key details/assumptions:

  • Logic relies on a consistent VIP collection handle and checking customer.tags.
  • Code snippets (search template and product template checks) are central to implementation.

Status: No confirmation of implementation success; discussion remains open without a final resolution.

Summarized with AI on December 10. AI used: gpt-5.

Hi everyone,

I want to hide certain products from customers who don’t have a specific tag. In other words, only customers with the “vip” tag should be able to see these products. I’ve already created a collection template that’s only visible to tagged VIP customers, but the products still appear in search results. Additionally, if I open the product’s URL directly, I can still access it without the tag.

How can I fully restrict access to these products so that only customers with the “vip” tag can view them?

1 Like
  1. You should edit the search template (probably search.liquid or search-results.liquid). Basically, we loop through the results and check if each product belongs to our VIP collection. If it does and the customer doesn’t have the VIP tag, we just skip displaying it.

    {% for item in search.results %}
    {% if item.object_type == ‘product’ %}
    {% comment %}Check if product is in VIP collection{% endcomment %}
    {% assign is_vip_product = false %}
    {% for collection in item.collections %}
    {% if collection.handle == ‘vip-products’ %}
    {% assign is_vip_product = true %}
    {% break %}
    {% endif %}
    {% endfor %}
    
    {% comment %}Only show if not VIP or customer has VIP tag{% endcomment %}
    {% if is_vip_product == false or customer.tags contains 'vip' %}
      {% comment %}Your normal search result display code here{% endcomment %}
      <div class="search-result">
        <a href="{{ item.url }}">{{ item.title }}</a>
      </div>
    {% endif %}
    
    {% else %}
    {% comment %}Display non-product results normally{% endcomment %}
    {% endif %}
    {% endfor %}
    
  2. To block direct url access, you need to add a check at the top of the product template (product.liquid). If someone lands on a VIP product page without the tag, we can redirect them or show an access denied message.

    {% comment %}Check if this product is in the VIP collection{% endcomment %}
    {% assign is_vip_product = false %}
    {% for collection in product.collections %}
    {% if collection.handle == ‘vip-products’ %}
    {% assign is_vip_product = true %}
    {% break %}
    {% endif %}
    {% endfor %}
    
    {% if is_vip_product and customer.tags contains ‘vip’ == false %}
    {% comment %}Redirect non-VIP customers{% endcomment %}
    
    <script>
        window.location.href = '/collections/all';
      </script>
    
    <div style="text-align: center; padding: 50px;">
        <h2>Access Restricted</h2>
        <p>This product is only available to VIP members.</p>
        <a href="/collections/all">Browse our other products</a>
      </div>
    {% else %}
      {% comment %}Your normal product template code here{% endcomment %}
      <h1>{{ product.title }}</h1>
      <div>{{ product.description }}</div>
      {% comment %}etc...{% endcomment %}
    {% endif %}
    
  3. Honestly, if this feels like too much manual work or we want something more secure, we could just use an app. Locksmith is really good for this kind of thing, or there’s Customer Accounts Concierge and Wholesale Club. They handle all the edge cases automatically and we wouldn’t have to worry about maintaining the code.

@Chrystel078 Thanks for reaching out to Shopify community with your concern. You need to modify search template (probably search.liquid or search-results.liquid) as mentioned above by Whaleshark and modify product template (product.liquid).

Additionally, you can implement a flow where customers attempting to access a product page directly are first prompted to log in. After they log in, you can verify—within the product template or VIP collection template—whether they qualify as VIP customers.

Implementing this functionality requires custom theme development and coding expertise. If you’re not comfortable making these changes yourself, your best option would be to hire a Shopify Partner or Expert. If you’d like to discuss this further, feel free to send me a private message.

Shopify has tools to hide product from search and search engines.
These are:

However, to prevent actual product page from being shown to people without tag you’d either need an app, like Locksmith or a code edit.

Say, you can modify the layouts/theme.liquid like this. It will redirect to the homepage if not vip trying to access the hidden product:

{% liquid 
  assign not_vip = true
  if customer and customer.tags contains "vip-tag" 
    assign not_vip = false
  endif

  assign hidden_product = false
  assign product_collections = product.collections | map: "handle"
  if product and product_collections contains "handle-of-hidden-collection"
    assign hidden_product = true
  endif
%}

{% if  hidden_product and not_vip %}
  <html>
   <head>
    <meta http-equiv="refresh" content="0;url={{ routes.root_url }}" />
   </head>
  </html>
{% else %}
  . . . <!-- content of your layout file -->
{% endif %}

Hi @Chrystel078 ,
Shopify doesn’t have built-in product-level access control, so even if you hide the collection, the product will still appear in search and will still be accessible by direct URL unless you block it in your theme logic.

To fully restrict the product, you need to add a customer-tag check inside your product template.

Solution: Hide the product page unless the customer has the “vip” tag

In your product.liquid or main product template, wrap the content with:

{% if customer and customer.tags contains 'vip' %}
  <!-- Product content -->
  {{ content_for_layout }}
{% else %}
  <div style="padding: 40px 0;">
    <h2>Restricted Product</h2>
    <p>This product is available only for VIP customers.</p>
  </div>
{% endif %}

Hide product from search & collection listings

In your product card or search results template, add:

{% if customer and customer.tags contains 'vip' %}
  <!-- Show product card -->
  …product card code…
{% else %}
  {% unless product.tags contains 'vip-only' %}
    …product card code…
  {% endunless %}
{% endif %}

Or simply add a tag like vip-only to products and use that to hide them from public results.